Mercurial > emacs
comparison src/data.c @ 52537:ab6a470dc45f
(Fvariable_binding_locus): New function.
(syms_of_data): defsubr it.
(Flocal_variable_p): Delete duplicate call to indirect_variable.
| author | Richard M. Stallman <rms@gnu.org> |
|---|---|
| date | Fri, 19 Sep 2003 14:34:30 +0000 |
| parents | 695cf19ef79e |
| children | 2d50b0e7a79c |
comparison
equal
deleted
inserted
replaced
| 52536:8fdcd48f4b33 | 52537:ab6a470dc45f |
|---|---|
| 1704 if (BUFFER_LOCAL_VALUEP (valcontents) | 1704 if (BUFFER_LOCAL_VALUEP (valcontents) |
| 1705 || SOME_BUFFER_LOCAL_VALUEP (valcontents)) | 1705 || SOME_BUFFER_LOCAL_VALUEP (valcontents)) |
| 1706 { | 1706 { |
| 1707 Lisp_Object tail, elt; | 1707 Lisp_Object tail, elt; |
| 1708 | 1708 |
| 1709 variable = indirect_variable (variable); | |
| 1710 for (tail = buf->local_var_alist; CONSP (tail); tail = XCDR (tail)) | 1709 for (tail = buf->local_var_alist; CONSP (tail); tail = XCDR (tail)) |
| 1711 { | 1710 { |
| 1712 elt = XCAR (tail); | 1711 elt = XCAR (tail); |
| 1713 if (EQ (variable, XCAR (elt))) | 1712 if (EQ (variable, XCAR (elt))) |
| 1714 return Qt; | 1713 return Qt; |
| 1761 elt = XCAR (tail); | 1760 elt = XCAR (tail); |
| 1762 if (EQ (variable, XCAR (elt))) | 1761 if (EQ (variable, XCAR (elt))) |
| 1763 return Qt; | 1762 return Qt; |
| 1764 } | 1763 } |
| 1765 } | 1764 } |
| 1765 return Qnil; | |
| 1766 } | |
| 1767 | |
| 1768 DEFUN ("variable-binding-locus", Fvariable_binding_locus, Svariable_binding_locus, | |
| 1769 1, 1, 0, | |
| 1770 doc: /* Return a value indicating where VARIABLE's current binding comes from. | |
| 1771 If the current binding is buffer-local, the value is the current buffer. | |
| 1772 If the current binding is frame-local, the value is the selected frame. | |
| 1773 If the current binding is global (the default), the value is nil. */) | |
| 1774 (variable) | |
| 1775 register Lisp_Object variable; | |
| 1776 { | |
| 1777 Lisp_Object valcontents; | |
| 1778 | |
| 1779 CHECK_SYMBOL (variable); | |
| 1780 variable = indirect_variable (variable); | |
| 1781 | |
| 1782 /* Make sure the current binding is actually swapped in. */ | |
| 1783 find_symbol_value (variable); | |
| 1784 | |
| 1785 valcontents = XSYMBOL (variable)->value; | |
| 1786 | |
| 1787 if (BUFFER_LOCAL_VALUEP (valcontents) | |
| 1788 || SOME_BUFFER_LOCAL_VALUEP (valcontents) | |
| 1789 || BUFFER_OBJFWDP (valcontents)) | |
| 1790 { | |
| 1791 /* For a local variable, record both the symbol and which | |
| 1792 buffer's or frame's value we are saving. */ | |
| 1793 if (!NILP (Flocal_variable_p (variable, Qnil))) | |
| 1794 return Fcurrent_buffer (); | |
| 1795 else if (!BUFFER_OBJFWDP (valcontents) | |
| 1796 && XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame) | |
| 1797 return XBUFFER_LOCAL_VALUE (valcontents)->frame; | |
| 1798 } | |
| 1799 | |
| 1766 return Qnil; | 1800 return Qnil; |
| 1767 } | 1801 } |
| 1768 | 1802 |
| 1769 /* Find the function at the end of a chain of symbol function indirections. */ | 1803 /* Find the function at the end of a chain of symbol function indirections. */ |
| 1770 | 1804 |
| 3183 defsubr (&Smake_local_variable); | 3217 defsubr (&Smake_local_variable); |
| 3184 defsubr (&Skill_local_variable); | 3218 defsubr (&Skill_local_variable); |
| 3185 defsubr (&Smake_variable_frame_local); | 3219 defsubr (&Smake_variable_frame_local); |
| 3186 defsubr (&Slocal_variable_p); | 3220 defsubr (&Slocal_variable_p); |
| 3187 defsubr (&Slocal_variable_if_set_p); | 3221 defsubr (&Slocal_variable_if_set_p); |
| 3222 defsubr (&Svariable_binding_locus); | |
| 3188 defsubr (&Saref); | 3223 defsubr (&Saref); |
| 3189 defsubr (&Saset); | 3224 defsubr (&Saset); |
| 3190 defsubr (&Snumber_to_string); | 3225 defsubr (&Snumber_to_string); |
| 3191 defsubr (&Sstring_to_number); | 3226 defsubr (&Sstring_to_number); |
| 3192 defsubr (&Seqlsign); | 3227 defsubr (&Seqlsign); |
