diff options
author | Karl Heuer <kwzh@gnu.org> | 1995-06-07 21:07:25 +0000 |
---|---|---|
committer | Karl Heuer <kwzh@gnu.org> | 1995-06-07 21:07:25 +0000 |
commit | 24651ae57b45d78f47b64e88bf6b3accf418db7a (patch) | |
tree | f8b0125e358b89712cf66faa50ef45e89c10b989 /src | |
parent | 31984859c9027a4a55c2d4a957271c6977c8c921 (diff) | |
download | emacs-24651ae57b45d78f47b64e88bf6b3accf418db7a.tar.gz |
(Flocal_variable_p): New optional arg BUFFER.
Really check whether var is local in *that* buffer.
Diffstat (limited to 'src')
-rw-r--r-- | src/data.c | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/src/data.c b/src/data.c index 55df5198401..be28445717d 100644 --- a/src/data.c +++ b/src/data.c @@ -1339,20 +1339,45 @@ From now on the default value will apply in this buffer.") } DEFUN ("local-variable-p", Flocal_variable_p, Slocal_variable_p, - 1, 1, 0, - "Non-nil if VARIABLE has a local binding in the current buffer.") - (sym) - register Lisp_Object sym; + 1, 2, 0, + "Non-nil if VARIABLE has a local binding in buffer BUFFER.\n\ +BUFFER defaults to the current buffer.") + (sym, buffer) + register Lisp_Object sym, buffer; { Lisp_Object valcontents; + register struct buffer *buf; + + if (NILP (buffer)) + buf = current_buffer; + else + { + CHECK_BUFFER (buffer, 0); + buf = XBUFFER (buffer); + } CHECK_SYMBOL (sym, 0); valcontents = XSYMBOL (sym)->value; - return ((BUFFER_LOCAL_VALUEP (valcontents) - || SOME_BUFFER_LOCAL_VALUEP (valcontents) - || BUFFER_OBJFWDP (valcontents)) - ? Qt : Qnil); + if (BUFFER_LOCAL_VALUEP (valcontents) + && SOME_BUFFER_LOCAL_VALUEP (valcontents)) + { + Lisp_Object tail, elt; + for (tail = buf->local_var_alist; CONSP (tail); tail = XCONS (tail)->cdr) + { + elt = XCONS (tail)->car; + if (EQ (sym, XCONS (elt)->car)) + return Qt; + } + } + if (BUFFER_OBJFWDP (valcontents)) + { + int offset = XBUFFER_OBJFWD (valcontents)->offset; + int mask = XINT (*(Lisp_Object *)(offset + (char *)&buffer_local_flags)); + if (mask == -1 || (buf->local_var_flags & mask)) + return Qt; + } + return Qnil; } /* Find the function at the end of a chain of symbol function indirections. */ |