# HG changeset patch # User Richard M. Stallman # Date 742714619 0 # Node ID f8c6e5e9603f50d7cc256f6562d736f0ab5913dd # Parent b6268758730985513e67d9bd56b82b429a7df28d (Fbuffer_local_variables): For local var that is unbound, put just the symbol in the result, not a cons of (symbol . value). diff -r b62687587309 -r f8c6e5e9603f src/buffer.c --- a/src/buffer.c Thu Jul 15 05:32:25 1993 +0000 +++ b/src/buffer.c Thu Jul 15 05:36:59 1993 +0000 @@ -400,14 +400,15 @@ DEFUN ("buffer-local-variables", Fbuffer_local_variables, Sbuffer_local_variables, 0, 1, 0, "Return an alist of variables that are buffer-local in BUFFER.\n\ -Each element looks like (SYMBOL . VALUE) and describes one variable.\n\ +Most elements look like (SYMBOL . VALUE), describing one variable.\n\ +For a symbol that is locally unbound, just the symbol appears in the value.\n\ Note that storing new VALUEs in these elements doesn't change the variables.\n\ No argument or nil as argument means use current buffer as BUFFER.") (buffer) register Lisp_Object buffer; { register struct buffer *buf; - register Lisp_Object val; + register Lisp_Object result; if (NILP (buffer)) buf = current_buffer; @@ -417,24 +418,35 @@ buf = XBUFFER (buffer); } + result = Qnil; + { /* Reference each variable in the alist in our current buffer. If inquiring about the current buffer, this gets the current values, so store them into the alist so the alist is up to date. If inquiring about some other buffer, this swaps out any values for that buffer, making the alist up to date automatically. */ - register Lisp_Object tem; - for (tem = buf->local_var_alist; CONSP (tem); tem = XCONS (tem)->cdr) + register Lisp_Object tail; + for (tail = buf->local_var_alist; CONSP (tail); tail = XCONS (tail)->cdr) { - Lisp_Object v1 = Fsymbol_value (XCONS (XCONS (tem)->car)->car); + Lisp_Object val, elt; + + elt = XCONS (tail)->car; + if (buf == current_buffer) - XCONS (XCONS (tem)->car)->cdr = v1; + val = find_symbol_value (XCONS (elt)->car); + else + val = XCONS (elt)->cdr; + + /* If symbol is unbound, put just the symbol in the list. */ + if (EQ (val, Qunbound)) + result = Fcons (XCONS (elt)->car, result); + /* Otherwise, put (symbol . value) in the list. */ + else + result = Fcons (Fcons (XCONS (elt)->car, val), result); } } - /* Make a copy of the alist, to return it. */ - val = Fcopy_alist (buf->local_var_alist); - /* Add on all the variables stored in special slots. */ { register int offset, mask; @@ -447,12 +459,13 @@ if (mask == -1 || (buf->local_var_flags & mask)) if (XTYPE (*(Lisp_Object *)(offset + (char *)&buffer_local_symbols)) == Lisp_Symbol) - val = Fcons (Fcons (*(Lisp_Object *)(offset + (char *)&buffer_local_symbols), - *(Lisp_Object *)(offset + (char *)buf)), - val); + result = Fcons (Fcons (*(Lisp_Object *)(offset + (char *)&buffer_local_symbols), + *(Lisp_Object *)(offset + (char *)buf)), + result); } } - return (val); + + return result; }