Mercurial > emacs
comparison src/data.c @ 12113:d96b45f31afa
(Flocal_variable_p): New optional arg BUFFER.
Really check whether var is local in *that* buffer.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Wed, 07 Jun 1995 21:07:25 +0000 |
parents | 4aed79cc70b7 |
children | a0067d2edef7 |
comparison
equal
deleted
inserted
replaced
12112:841aa5ac0f46 | 12113:d96b45f31afa |
---|---|
1337 | 1337 |
1338 return sym; | 1338 return sym; |
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. */ |
1359 | 1384 |
1360 /* If OBJECT is a symbol, find the end of its function chain and | 1385 /* If OBJECT is a symbol, find the end of its function chain and |