diff options
| author | Richard M. Stallman | 2000-02-15 09:57:33 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2000-02-15 09:57:33 +0000 |
| commit | 1f35ce36c2bac1e11b8dea2d6e39a9dccbc2b17b (patch) | |
| tree | 9abbfd75276782a3dbb14320003f790dffffb2cd /src | |
| parent | 6ffd3cf7016259b41cdb14e36780783e88730b48 (diff) | |
| download | emacs-1f35ce36c2bac1e11b8dea2d6e39a9dccbc2b17b.tar.gz emacs-1f35ce36c2bac1e11b8dea2d6e39a9dccbc2b17b.zip | |
(set_internal): Don't make variable buffer-local
if within a let-binding for the same buffer.
(let_shadows_buffer_binding_p): New function.
Diffstat (limited to 'src')
| -rw-r--r-- | src/data.c | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/src/data.c b/src/data.c index eb29de20dbd..669efa5802e 100644 --- a/src/data.c +++ b/src/data.c | |||
| @@ -962,6 +962,23 @@ DEFUN ("set", Fset, Sset, 2, 2, 0, | |||
| 962 | return set_internal (symbol, newval, current_buffer, 0); | 962 | return set_internal (symbol, newval, current_buffer, 0); |
| 963 | } | 963 | } |
| 964 | 964 | ||
| 965 | /* Return 1 if SYMBOL currently has a let-binding | ||
| 966 | which was made in the buffer that is now current. */ | ||
| 967 | |||
| 968 | static int | ||
| 969 | let_shadows_buffer_binding_p (symbol) | ||
| 970 | Lisp_Object symbol; | ||
| 971 | { | ||
| 972 | struct specbinding *p; | ||
| 973 | |||
| 974 | for (p = specpdl_ptr - 1; p >= specpdl; p--) | ||
| 975 | if (p->func == 0 && CONSP (p->symbol) | ||
| 976 | && XBUFFER (XCDR (XCDR (p->symbol))) == current_buffer) | ||
| 977 | return 1; | ||
| 978 | |||
| 979 | return 0; | ||
| 980 | } | ||
| 981 | |||
| 965 | /* Store the value NEWVAL into SYMBOL. | 982 | /* Store the value NEWVAL into SYMBOL. |
| 966 | If buffer-locality is an issue, BUF specifies which buffer to use. | 983 | If buffer-locality is an issue, BUF specifies which buffer to use. |
| 967 | (0 stands for the current buffer.) | 984 | (0 stands for the current buffer.) |
| @@ -1000,7 +1017,8 @@ set_internal (symbol, newval, buf, bindflag) | |||
| 1000 | register int idx = XBUFFER_OBJFWD (valcontents)->offset; | 1017 | register int idx = XBUFFER_OBJFWD (valcontents)->offset; |
| 1001 | register int mask = XINT (*((Lisp_Object *) | 1018 | register int mask = XINT (*((Lisp_Object *) |
| 1002 | (idx + (char *)&buffer_local_flags))); | 1019 | (idx + (char *)&buffer_local_flags))); |
| 1003 | if (mask > 0 && ! bindflag) | 1020 | if (mask > 0 && ! bindflag |
| 1021 | && ! let_shadows_buffer_binding_p (symbol)) | ||
| 1004 | buf->local_var_flags |= mask; | 1022 | buf->local_var_flags |= mask; |
| 1005 | } | 1023 | } |
| 1006 | 1024 | ||
| @@ -1068,8 +1086,11 @@ set_internal (symbol, newval, buf, bindflag) | |||
| 1068 | /* If the variable is a Lisp_Some_Buffer_Local_Value, | 1086 | /* If the variable is a Lisp_Some_Buffer_Local_Value, |
| 1069 | or if this is `let' rather than `set', | 1087 | or if this is `let' rather than `set', |
| 1070 | make CURRENT-ALIST-ELEMENT point to itself, | 1088 | make CURRENT-ALIST-ELEMENT point to itself, |
| 1071 | indicating that we're seeing the default value. */ | 1089 | indicating that we're seeing the default value. |
| 1072 | if (bindflag || SOME_BUFFER_LOCAL_VALUEP (valcontents)) | 1090 | Likewise if the variable has been let-bound |
| 1091 | in the current buffer. */ | ||
| 1092 | if (bindflag || SOME_BUFFER_LOCAL_VALUEP (valcontents) | ||
| 1093 | || let_shadows_buffer_binding_p (symbol)) | ||
| 1073 | { | 1094 | { |
| 1074 | XBUFFER_LOCAL_VALUE (valcontents)->found_for_buffer = 0; | 1095 | XBUFFER_LOCAL_VALUE (valcontents)->found_for_buffer = 0; |
| 1075 | 1096 | ||
| @@ -1083,8 +1104,10 @@ set_internal (symbol, newval, buf, bindflag) | |||
| 1083 | tem1 = XBUFFER_LOCAL_VALUE (valcontents)->cdr; | 1104 | tem1 = XBUFFER_LOCAL_VALUE (valcontents)->cdr; |
| 1084 | } | 1105 | } |
| 1085 | /* If it's a Lisp_Buffer_Local_Value, being set not bound, | 1106 | /* If it's a Lisp_Buffer_Local_Value, being set not bound, |
| 1086 | give this buffer a new assoc for a local value and set | 1107 | and we're not within a let that was made for this buffer, |
| 1087 | CURRENT-ALIST-ELEMENT to point to that. */ | 1108 | create a new buffer-local binding for the variable. |
| 1109 | That means, give this buffer a new assoc for a local value | ||
| 1110 | and set CURRENT-ALIST-ELEMENT to point to that. */ | ||
| 1088 | else | 1111 | else |
| 1089 | { | 1112 | { |
| 1090 | tem1 = Fcons (symbol, Fcdr (current_alist_element)); | 1113 | tem1 = Fcons (symbol, Fcdr (current_alist_element)); |