diff options
| author | Karl Heuer | 1995-06-07 21:07:25 +0000 |
|---|---|---|
| committer | Karl Heuer | 1995-06-07 21:07:25 +0000 |
| commit | c48ead865994e2debfd876b1c454adf5a3dd4459 (patch) | |
| tree | f3f0922b4359c567bd586fbc922cb2c620ec5c62 /src/data.c | |
| parent | 79069c68693a3ae6b1f9de19332f1ba5a08c1611 (diff) | |
| download | emacs-c48ead865994e2debfd876b1c454adf5a3dd4459.tar.gz emacs-c48ead865994e2debfd876b1c454adf5a3dd4459.zip | |
(Flocal_variable_p): New optional arg BUFFER.
Really check whether var is local in *that* buffer.
Diffstat (limited to 'src/data.c')
| -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.") | |||
| 1339 | } | 1339 | } |
| 1340 | 1340 | ||
| 1341 | DEFUN ("local-variable-p", Flocal_variable_p, Slocal_variable_p, | 1341 | DEFUN ("local-variable-p", Flocal_variable_p, Slocal_variable_p, |
| 1342 | 1, 1, 0, | 1342 | 1, 2, 0, |
| 1343 | "Non-nil if VARIABLE has a local binding in the current buffer.") | 1343 | "Non-nil if VARIABLE has a local binding in buffer BUFFER.\n\ |
| 1344 | (sym) | 1344 | BUFFER defaults to the current buffer.") |
| 1345 | register Lisp_Object sym; | 1345 | (sym, buffer) |
| 1346 | register Lisp_Object sym, buffer; | ||
| 1346 | { | 1347 | { |
| 1347 | Lisp_Object valcontents; | 1348 | Lisp_Object valcontents; |
| 1349 | register struct buffer *buf; | ||
| 1350 | |||
| 1351 | if (NILP (buffer)) | ||
| 1352 | buf = current_buffer; | ||
| 1353 | else | ||
| 1354 | { | ||
| 1355 | CHECK_BUFFER (buffer, 0); | ||
| 1356 | buf = XBUFFER (buffer); | ||
| 1357 | } | ||
| 1348 | 1358 | ||
| 1349 | CHECK_SYMBOL (sym, 0); | 1359 | CHECK_SYMBOL (sym, 0); |
| 1350 | 1360 | ||
| 1351 | valcontents = XSYMBOL (sym)->value; | 1361 | valcontents = XSYMBOL (sym)->value; |
| 1352 | return ((BUFFER_LOCAL_VALUEP (valcontents) | 1362 | if (BUFFER_LOCAL_VALUEP (valcontents) |
| 1353 | || SOME_BUFFER_LOCAL_VALUEP (valcontents) | 1363 | && SOME_BUFFER_LOCAL_VALUEP (valcontents)) |
| 1354 | || BUFFER_OBJFWDP (valcontents)) | 1364 | { |
| 1355 | ? Qt : Qnil); | 1365 | Lisp_Object tail, elt; |
| 1366 | for (tail = buf->local_var_alist; CONSP (tail); tail = XCONS (tail)->cdr) | ||
| 1367 | { | ||
| 1368 | elt = XCONS (tail)->car; | ||
| 1369 | if (EQ (sym, XCONS (elt)->car)) | ||
| 1370 | return Qt; | ||
| 1371 | } | ||
| 1372 | } | ||
| 1373 | if (BUFFER_OBJFWDP (valcontents)) | ||
| 1374 | { | ||
| 1375 | int offset = XBUFFER_OBJFWD (valcontents)->offset; | ||
| 1376 | int mask = XINT (*(Lisp_Object *)(offset + (char *)&buffer_local_flags)); | ||
| 1377 | if (mask == -1 || (buf->local_var_flags & mask)) | ||
| 1378 | return Qt; | ||
| 1379 | } | ||
| 1380 | return Qnil; | ||
| 1356 | } | 1381 | } |
| 1357 | 1382 | ||
| 1358 | /* Find the function at the end of a chain of symbol function indirections. */ | 1383 | /* Find the function at the end of a chain of symbol function indirections. */ |