diff options
author | Richard M. Stallman <rms@gnu.org> | 1993-07-15 05:36:59 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 1993-07-15 05:36:59 +0000 |
commit | 553defa4042c7f99eb1cce76f40f86bc41a6bd3a (patch) | |
tree | 05749ed3324b309f47a619ac4fef53f8b86516af /src/buffer.c | |
parent | fc53efda7ff7c404586c4cd66559568c8006c225 (diff) | |
download | emacs-553defa4042c7f99eb1cce76f40f86bc41a6bd3a.tar.gz |
(Fbuffer_local_variables): For local var that is unbound,
put just the symbol in the result, not a cons of (symbol . value).
Diffstat (limited to 'src/buffer.c')
-rw-r--r-- | src/buffer.c | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/src/buffer.c b/src/buffer.c index ce07c2a21d3..b12ce2ac141 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -400,14 +400,15 @@ No argument or nil as argument means use the current buffer.") 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 @@ No argument or nil as argument means use current buffer as BUFFER.") 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 @@ No argument or nil as argument means use current buffer as BUFFER.") 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; } |