diff options
| author | Eli Zaretskii | 2024-11-10 20:49:45 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2024-11-10 20:49:45 +0200 |
| commit | 90c97d3fac989f3048fda4a30a626bec2c3301c5 (patch) | |
| tree | e1044348239560496cf8055ee8c3b0c6d5be9416 /src | |
| parent | c96e57609076c4d5627e698a6f12a731a77c365e (diff) | |
| download | emacs-90c97d3fac989f3048fda4a30a626bec2c3301c5.tar.gz emacs-90c97d3fac989f3048fda4a30a626bec2c3301c5.zip | |
Fix handling of permanent-local variables in 'kill-all-local-variables'
The original implementation went too far and caused unexpected
results.
* src/buffer.c (reset_buffer_local_variables): Second argument is
now 'int', and can be 0, 1, or 2.
(Fkill_all_local_variables): Call 'reset_buffer_local_variables'
with 2nd argument 2 if KILL-PERMANENT is non-nil. (Bug#74091)
Diffstat (limited to 'src')
| -rw-r--r-- | src/buffer.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/buffer.c b/src/buffer.c index 744b0ef5548..995984e3e72 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -113,7 +113,7 @@ static int last_per_buffer_idx; | |||
| 113 | static void call_overlay_mod_hooks (Lisp_Object list, Lisp_Object overlay, | 113 | static void call_overlay_mod_hooks (Lisp_Object list, Lisp_Object overlay, |
| 114 | bool after, Lisp_Object arg1, | 114 | bool after, Lisp_Object arg1, |
| 115 | Lisp_Object arg2, Lisp_Object arg3); | 115 | Lisp_Object arg2, Lisp_Object arg3); |
| 116 | static void reset_buffer_local_variables (struct buffer *, bool); | 116 | static void reset_buffer_local_variables (struct buffer *, int); |
| 117 | 117 | ||
| 118 | /* Alist of all buffer names vs the buffers. This used to be | 118 | /* Alist of all buffer names vs the buffers. This used to be |
| 119 | a Lisp-visible variable, but is no longer, to prevent lossage | 119 | a Lisp-visible variable, but is no longer, to prevent lossage |
| @@ -1112,10 +1112,11 @@ reset_buffer (register struct buffer *b) | |||
| 1112 | Instead, use Fkill_all_local_variables. | 1112 | Instead, use Fkill_all_local_variables. |
| 1113 | 1113 | ||
| 1114 | If PERMANENT_TOO, reset permanent buffer-local variables. | 1114 | If PERMANENT_TOO, reset permanent buffer-local variables. |
| 1115 | If not, preserve those. */ | 1115 | If not, preserve those. PERMANENT_TOO = 2 means ignore |
| 1116 | the permanent-local property of non-builtin variables. */ | ||
| 1116 | 1117 | ||
| 1117 | static void | 1118 | static void |
| 1118 | reset_buffer_local_variables (struct buffer *b, bool permanent_too) | 1119 | reset_buffer_local_variables (struct buffer *b, int permanent_too) |
| 1119 | { | 1120 | { |
| 1120 | int offset, i; | 1121 | int offset, i; |
| 1121 | 1122 | ||
| @@ -1141,7 +1142,7 @@ reset_buffer_local_variables (struct buffer *b, bool permanent_too) | |||
| 1141 | bset_invisibility_spec (b, Qt); | 1142 | bset_invisibility_spec (b, Qt); |
| 1142 | 1143 | ||
| 1143 | /* Reset all (or most) per-buffer variables to their defaults. */ | 1144 | /* Reset all (or most) per-buffer variables to their defaults. */ |
| 1144 | if (permanent_too) | 1145 | if (permanent_too == 1) |
| 1145 | bset_local_var_alist (b, Qnil); | 1146 | bset_local_var_alist (b, Qnil); |
| 1146 | else | 1147 | else |
| 1147 | { | 1148 | { |
| @@ -1170,7 +1171,7 @@ reset_buffer_local_variables (struct buffer *b, bool permanent_too) | |||
| 1170 | swap_in_global_binding (XSYMBOL (sym)); | 1171 | swap_in_global_binding (XSYMBOL (sym)); |
| 1171 | } | 1172 | } |
| 1172 | 1173 | ||
| 1173 | if (!NILP (prop)) | 1174 | if (!NILP (prop) && !permanent_too) |
| 1174 | { | 1175 | { |
| 1175 | /* If permanent-local, keep it. */ | 1176 | /* If permanent-local, keep it. */ |
| 1176 | last = tmp; | 1177 | last = tmp; |
| @@ -3001,7 +3002,7 @@ the normal hook `change-major-mode-hook'. */) | |||
| 3001 | 3002 | ||
| 3002 | /* Actually eliminate all local bindings of this buffer. */ | 3003 | /* Actually eliminate all local bindings of this buffer. */ |
| 3003 | 3004 | ||
| 3004 | reset_buffer_local_variables (current_buffer, !NILP (kill_permanent)); | 3005 | reset_buffer_local_variables (current_buffer, !NILP (kill_permanent) ? 2 : 0); |
| 3005 | 3006 | ||
| 3006 | /* Force mode-line redisplay. Useful here because all major mode | 3007 | /* Force mode-line redisplay. Useful here because all major mode |
| 3007 | commands call this function. */ | 3008 | commands call this function. */ |