diff options
| author | Stefan Monnier | 2007-12-10 03:47:46 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2007-12-10 03:47:46 +0000 |
| commit | 3709505e05ef3670b630fa3bbb2c154113cbb322 (patch) | |
| tree | 8dc67dc19e037467151205c46d7a5f3f49d1063a /src | |
| parent | 59ab76755818a07c3e8619b73aee353ed17e6bc2 (diff) | |
| download | emacs-3709505e05ef3670b630fa3bbb2c154113cbb322.tar.gz emacs-3709505e05ef3670b630fa3bbb2c154113cbb322.zip | |
(reset_buffer_local_variables): If permanent_too is 0, also
preserve non-built-in buffer-local variables.
(Fkill_all_local_variables): Don't re-create&re-set permanent
buffer-local variables.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 13 | ||||
| -rw-r--r-- | src/buffer.c | 54 |
2 files changed, 40 insertions, 27 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 1ac5cc65241..86bfa0ab211 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,16 @@ | |||
| 1 | 2007-12-10 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * keyboard.c (Fcommand_execute): Call Qcall_interactively instead of | ||
| 4 | manipulating the backtrace manually. | ||
| 5 | (make_lispy_event): Merge the ASCII and MULTIBYTE cases. | ||
| 6 | (struct backtrace, backtrace_list): Remove. | ||
| 7 | (command_loop_1): Remove dead var `no_direct'. | ||
| 8 | |||
| 9 | * buffer.c (reset_buffer_local_variables): If permanent_too is 0, also | ||
| 10 | preserve non-built-in buffer-local variables. | ||
| 11 | (Fkill_all_local_variables): Don't re-create&re-set permanent | ||
| 12 | buffer-local variables. | ||
| 13 | |||
| 1 | 2007-12-09 Juri Linkov <juri@jurta.org> | 14 | 2007-12-09 Juri Linkov <juri@jurta.org> |
| 2 | 15 | ||
| 3 | * buffer.c (Frename_buffer): Change interactive spec from "s" to | 16 | * buffer.c (Frename_buffer): Change interactive spec from "s" to |
diff --git a/src/buffer.c b/src/buffer.c index cfaacc28905..44c449767c3 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -107,12 +107,14 @@ static char buffer_permanent_local_flags[MAX_PER_BUFFER_VARS]; | |||
| 107 | 107 | ||
| 108 | int last_per_buffer_idx; | 108 | int last_per_buffer_idx; |
| 109 | 109 | ||
| 110 | Lisp_Object Fset_buffer (); | 110 | EXFUN (Fset_buffer, 1); |
| 111 | void set_buffer_internal (); | 111 | void set_buffer_internal P_ ((struct buffer *b)); |
| 112 | void set_buffer_internal_1 (); | 112 | void set_buffer_internal_1 P_ ((struct buffer *b)); |
| 113 | static void call_overlay_mod_hooks (); | 113 | static void call_overlay_mod_hooks P_ ((Lisp_Object list, Lisp_Object overlay, |
| 114 | static void swap_out_buffer_local_variables (); | 114 | int after, Lisp_Object arg1, |
| 115 | static void reset_buffer_local_variables (); | 115 | Lisp_Object arg2, Lisp_Object arg3)); |
| 116 | static void swap_out_buffer_local_variables P_ ((struct buffer *b)); | ||
| 117 | static void reset_buffer_local_variables P_ ((struct buffer *b, int permanent_too)); | ||
| 116 | 118 | ||
| 117 | /* Alist of all buffer names vs the buffers. */ | 119 | /* Alist of all buffer names vs the buffers. */ |
| 118 | /* This used to be a variable, but is no longer, | 120 | /* This used to be a variable, but is no longer, |
| @@ -716,7 +718,7 @@ reset_buffer (b) | |||
| 716 | it does not treat permanent locals consistently. | 718 | it does not treat permanent locals consistently. |
| 717 | Instead, use Fkill_all_local_variables. | 719 | Instead, use Fkill_all_local_variables. |
| 718 | 720 | ||
| 719 | If PERMANENT_TOO is 1, then we reset permanent built-in | 721 | If PERMANENT_TOO is 1, then we reset permanent |
| 720 | buffer-local variables. If PERMANENT_TOO is 0, | 722 | buffer-local variables. If PERMANENT_TOO is 0, |
| 721 | we preserve those. */ | 723 | we preserve those. */ |
| 722 | 724 | ||
| @@ -754,7 +756,23 @@ reset_buffer_local_variables (b, permanent_too) | |||
| 754 | #endif | 756 | #endif |
| 755 | 757 | ||
| 756 | /* Reset all (or most) per-buffer variables to their defaults. */ | 758 | /* Reset all (or most) per-buffer variables to their defaults. */ |
| 757 | b->local_var_alist = Qnil; | 759 | if (permanent_too) |
| 760 | b->local_var_alist = Qnil; | ||
| 761 | else | ||
| 762 | { | ||
| 763 | Lisp_Object tmp, last = Qnil; | ||
| 764 | for (tmp = b->local_var_alist; CONSP (tmp); tmp = XCDR (tmp)) | ||
| 765 | if (CONSP (XCAR (tmp)) | ||
| 766 | && SYMBOLP (XCAR (XCAR (tmp))) | ||
| 767 | && !NILP (Fget (XCAR (XCAR (tmp)), Qpermanent_local))) | ||
| 768 | /* If permanent-local, keep it. */ | ||
| 769 | last = tmp; | ||
| 770 | else if (NILP (last)) | ||
| 771 | b->local_var_alist = XCDR (tmp); | ||
| 772 | else | ||
| 773 | XSETCDR (last, XCDR (tmp)); | ||
| 774 | } | ||
| 775 | |||
| 758 | for (i = 0; i < last_per_buffer_idx; ++i) | 776 | for (i = 0; i < last_per_buffer_idx; ++i) |
| 759 | if (permanent_too || buffer_permanent_local_flags[i] == 0) | 777 | if (permanent_too || buffer_permanent_local_flags[i] == 0) |
| 760 | SET_PER_BUFFER_VALUE_P (b, i, 0); | 778 | SET_PER_BUFFER_VALUE_P (b, i, 0); |
| @@ -2452,14 +2470,10 @@ The first thing this function does is run | |||
| 2452 | the normal hook `change-major-mode-hook'. */) | 2470 | the normal hook `change-major-mode-hook'. */) |
| 2453 | () | 2471 | () |
| 2454 | { | 2472 | { |
| 2455 | register Lisp_Object alist, sym, tem; | ||
| 2456 | Lisp_Object oalist; | ||
| 2457 | |||
| 2458 | if (!NILP (Vrun_hooks)) | 2473 | if (!NILP (Vrun_hooks)) |
| 2459 | call1 (Vrun_hooks, Qchange_major_mode_hook); | 2474 | call1 (Vrun_hooks, Qchange_major_mode_hook); |
| 2460 | oalist = current_buffer->local_var_alist; | ||
| 2461 | 2475 | ||
| 2462 | /* Make sure none of the bindings in oalist | 2476 | /* Make sure none of the bindings in local_var_alist |
| 2463 | remain swapped in, in their symbols. */ | 2477 | remain swapped in, in their symbols. */ |
| 2464 | 2478 | ||
| 2465 | swap_out_buffer_local_variables (current_buffer); | 2479 | swap_out_buffer_local_variables (current_buffer); |
| @@ -2468,20 +2482,6 @@ the normal hook `change-major-mode-hook'. */) | |||
| 2468 | 2482 | ||
| 2469 | reset_buffer_local_variables (current_buffer, 0); | 2483 | reset_buffer_local_variables (current_buffer, 0); |
| 2470 | 2484 | ||
| 2471 | /* Any which are supposed to be permanent, | ||
| 2472 | make local again, with the same values they had. */ | ||
| 2473 | |||
| 2474 | for (alist = oalist; CONSP (alist); alist = XCDR (alist)) | ||
| 2475 | { | ||
| 2476 | sym = XCAR (XCAR (alist)); | ||
| 2477 | tem = Fget (sym, Qpermanent_local); | ||
| 2478 | if (! NILP (tem)) | ||
| 2479 | { | ||
| 2480 | Fmake_local_variable (sym); | ||
| 2481 | Fset (sym, XCDR (XCAR (alist))); | ||
| 2482 | } | ||
| 2483 | } | ||
| 2484 | |||
| 2485 | /* Force mode-line redisplay. Useful here because all major mode | 2485 | /* Force mode-line redisplay. Useful here because all major mode |
| 2486 | commands call this function. */ | 2486 | commands call this function. */ |
| 2487 | update_mode_lines++; | 2487 | update_mode_lines++; |