diff options
| author | Richard M. Stallman | 2005-03-17 23:37:39 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2005-03-17 23:37:39 +0000 |
| commit | e1688f54df958f9827dc7274521979254a159ae1 (patch) | |
| tree | e4c8c7b6452d3d458fd8f00a79ad3ee1daeedfdf /src/buffer.c | |
| parent | 7c0f6118c356ee202850cd50ff0f4b35ed7e5baa (diff) | |
| download | emacs-e1688f54df958f9827dc7274521979254a159ae1.tar.gz emacs-e1688f54df958f9827dc7274521979254a159ae1.zip | |
(buffer_lisp_local_variables): New function,
broken out from Fbuffer_local_variables.
(clone_per_buffer_values): Use buffer_lisp_local_variables.
Diffstat (limited to 'src/buffer.c')
| -rw-r--r-- | src/buffer.c | 79 |
1 files changed, 42 insertions, 37 deletions
diff --git a/src/buffer.c b/src/buffer.c index 8738466abd1..c934bdf22c3 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -182,6 +182,7 @@ static void alloc_buffer_text P_ ((struct buffer *, size_t)); | |||
| 182 | static void free_buffer_text P_ ((struct buffer *b)); | 182 | static void free_buffer_text P_ ((struct buffer *b)); |
| 183 | static struct Lisp_Overlay * copy_overlays P_ ((struct buffer *, struct Lisp_Overlay *)); | 183 | static struct Lisp_Overlay * copy_overlays P_ ((struct buffer *, struct Lisp_Overlay *)); |
| 184 | static void modify_overlay P_ ((struct buffer *, EMACS_INT, EMACS_INT)); | 184 | static void modify_overlay P_ ((struct buffer *, EMACS_INT, EMACS_INT)); |
| 185 | static Lisp_Object buffer_lisp_local_variables P_ ((struct buffer *)); | ||
| 185 | 186 | ||
| 186 | 187 | ||
| 187 | /* For debugging; temporary. See set_buffer_internal. */ | 188 | /* For debugging; temporary. See set_buffer_internal. */ |
| @@ -515,16 +516,11 @@ clone_per_buffer_values (from, to) | |||
| 515 | to->overlays_before = copy_overlays (to, from->overlays_before); | 516 | to->overlays_before = copy_overlays (to, from->overlays_before); |
| 516 | to->overlays_after = copy_overlays (to, from->overlays_after); | 517 | to->overlays_after = copy_overlays (to, from->overlays_after); |
| 517 | 518 | ||
| 518 | /* Copy the alist of local variables, | 519 | /* Get (a copy of) the alist of Lisp-level local variables of FROM |
| 519 | and all the alist elements too. */ | 520 | and install that in TO. */ |
| 520 | to->local_var_alist | 521 | to->local_var_alist = buffer_lisp_local_variables (from); |
| 521 | = Fcopy_sequence (from->local_var_alist); | ||
| 522 | for (tem = to->local_var_alist; CONSP (tem); | ||
| 523 | tem = XCDR (tem)) | ||
| 524 | XSETCAR (tem, Fcons (XCAR (XCAR (tem)), XCDR (XCAR (tem)))); | ||
| 525 | } | 522 | } |
| 526 | 523 | ||
| 527 | |||
| 528 | DEFUN ("make-indirect-buffer", Fmake_indirect_buffer, Smake_indirect_buffer, | 524 | DEFUN ("make-indirect-buffer", Fmake_indirect_buffer, Smake_indirect_buffer, |
| 529 | 2, 3, | 525 | 2, 3, |
| 530 | "bMake indirect buffer (to buffer): \nBName of indirect buffer: ", | 526 | "bMake indirect buffer (to buffer): \nBName of indirect buffer: ", |
| @@ -934,6 +930,43 @@ is the default binding of variable. */) | |||
| 934 | return result; | 930 | return result; |
| 935 | } | 931 | } |
| 936 | 932 | ||
| 933 | /* Return an alist of the Lisp-level buffer-local bindings of | ||
| 934 | buffer BUF. That is, do't include the variables maintained | ||
| 935 | in special slots in the buffer object. */ | ||
| 936 | |||
| 937 | static Lisp_Object | ||
| 938 | buffer_lisp_local_variables (buf) | ||
| 939 | struct buffer *buf; | ||
| 940 | { | ||
| 941 | Lisp_Object result = Qnil; | ||
| 942 | register Lisp_Object tail; | ||
| 943 | for (tail = buf->local_var_alist; CONSP (tail); tail = XCDR (tail)) | ||
| 944 | { | ||
| 945 | Lisp_Object val, elt; | ||
| 946 | |||
| 947 | elt = XCAR (tail); | ||
| 948 | |||
| 949 | /* Reference each variable in the alist in buf. | ||
| 950 | If inquiring about the current buffer, this gets the current values, | ||
| 951 | so store them into the alist so the alist is up to date. | ||
| 952 | If inquiring about some other buffer, this swaps out any values | ||
| 953 | for that buffer, making the alist up to date automatically. */ | ||
| 954 | val = find_symbol_value (XCAR (elt)); | ||
| 955 | /* Use the current buffer value only if buf is the current buffer. */ | ||
| 956 | if (buf != current_buffer) | ||
| 957 | val = XCDR (elt); | ||
| 958 | |||
| 959 | /* If symbol is unbound, put just the symbol in the list. */ | ||
| 960 | if (EQ (val, Qunbound)) | ||
| 961 | result = Fcons (XCAR (elt), result); | ||
| 962 | /* Otherwise, put (symbol . value) in the list. */ | ||
| 963 | else | ||
| 964 | result = Fcons (Fcons (XCAR (elt), val), result); | ||
| 965 | } | ||
| 966 | |||
| 967 | return result; | ||
| 968 | } | ||
| 969 | |||
| 937 | DEFUN ("buffer-local-variables", Fbuffer_local_variables, | 970 | DEFUN ("buffer-local-variables", Fbuffer_local_variables, |
| 938 | Sbuffer_local_variables, 0, 1, 0, | 971 | Sbuffer_local_variables, 0, 1, 0, |
| 939 | doc: /* Return an alist of variables that are buffer-local in BUFFER. | 972 | doc: /* Return an alist of variables that are buffer-local in BUFFER. |
| @@ -955,34 +988,7 @@ No argument or nil as argument means use current buffer as BUFFER. */) | |||
| 955 | buf = XBUFFER (buffer); | 988 | buf = XBUFFER (buffer); |
| 956 | } | 989 | } |
| 957 | 990 | ||
| 958 | result = Qnil; | 991 | result = buffer_lisp_local_variables (buf); |
| 959 | |||
| 960 | { | ||
| 961 | register Lisp_Object tail; | ||
| 962 | for (tail = buf->local_var_alist; CONSP (tail); tail = XCDR (tail)) | ||
| 963 | { | ||
| 964 | Lisp_Object val, elt; | ||
| 965 | |||
| 966 | elt = XCAR (tail); | ||
| 967 | |||
| 968 | /* Reference each variable in the alist in buf. | ||
| 969 | If inquiring about the current buffer, this gets the current values, | ||
| 970 | so store them into the alist so the alist is up to date. | ||
| 971 | If inquiring about some other buffer, this swaps out any values | ||
| 972 | for that buffer, making the alist up to date automatically. */ | ||
| 973 | val = find_symbol_value (XCAR (elt)); | ||
| 974 | /* Use the current buffer value only if buf is the current buffer. */ | ||
| 975 | if (buf != current_buffer) | ||
| 976 | val = XCDR (elt); | ||
| 977 | |||
| 978 | /* If symbol is unbound, put just the symbol in the list. */ | ||
| 979 | if (EQ (val, Qunbound)) | ||
| 980 | result = Fcons (XCAR (elt), result); | ||
| 981 | /* Otherwise, put (symbol . value) in the list. */ | ||
| 982 | else | ||
| 983 | result = Fcons (Fcons (XCAR (elt), val), result); | ||
| 984 | } | ||
| 985 | } | ||
| 986 | 992 | ||
| 987 | /* Add on all the variables stored in special slots. */ | 993 | /* Add on all the variables stored in special slots. */ |
| 988 | { | 994 | { |
| @@ -1004,7 +1010,6 @@ No argument or nil as argument means use current buffer as BUFFER. */) | |||
| 1004 | 1010 | ||
| 1005 | return result; | 1011 | return result; |
| 1006 | } | 1012 | } |
| 1007 | |||
| 1008 | 1013 | ||
| 1009 | DEFUN ("buffer-modified-p", Fbuffer_modified_p, Sbuffer_modified_p, | 1014 | DEFUN ("buffer-modified-p", Fbuffer_modified_p, Sbuffer_modified_p, |
| 1010 | 0, 1, 0, | 1015 | 0, 1, 0, |