summaryrefslogtreecommitdiff
path: root/src/data.c
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1995-06-17 19:47:30 +0000
committerRichard M. Stallman <rms@gnu.org>1995-06-17 19:47:30 +0000
commitd4952702b514712d34280bf4af06751e3c725301 (patch)
treee2debb39ccbb99b5f727e3fa6670b6828ad5c762 /src/data.c
parent77fcee4d48a90cad8cefd6850dc7393b2c21da58 (diff)
downloademacs-d4952702b514712d34280bf4af06751e3c725301.tar.gz
(Flocal_variable_if_set_p): New function.
(syms_of_data): Call defsubr.
Diffstat (limited to 'src/data.c')
-rw-r--r--src/data.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/data.c b/src/data.c
index a40f94d05db..44f651d7c1d 100644
--- a/src/data.c
+++ b/src/data.c
@@ -1379,6 +1379,47 @@ BUFFER defaults to the current buffer.")
}
return Qnil;
}
+
+DEFUN ("local-variable-if-set-p", Flocal_variable_if_set_p, Slocal_variable_if_set_p,
+ 1, 2, 0,
+ "Non-nil if VARIABLE will be local in buffer BUFFER if it is set there.\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;
+
+ /* This means that make-variable-buffer-local was done. */
+ if (BUFFER_LOCAL_VALUEP (valcontents))
+ return Qt;
+ /* All these slots become local if they are set. */
+ if (BUFFER_OBJFWDP (valcontents))
+ return Qt;
+ if (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;
+ }
+ }
+ return Qnil;
+}
/* Find the function at the end of a chain of symbol function indirections. */
@@ -2468,6 +2509,7 @@ syms_of_data ()
defsubr (&Smake_local_variable);
defsubr (&Skill_local_variable);
defsubr (&Slocal_variable_p);
+ defsubr (&Slocal_variable_if_set_p);
defsubr (&Saref);
defsubr (&Saset);
defsubr (&Snumber_to_string);