diff options
Diffstat (limited to 'src/buffer.c')
| -rw-r--r-- | src/buffer.c | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/src/buffer.c b/src/buffer.c index 77af23ace39..009d7de86fc 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, |
| @@ -717,7 +719,7 @@ reset_buffer (b) | |||
| 717 | it does not treat permanent locals consistently. | 719 | it does not treat permanent locals consistently. |
| 718 | Instead, use Fkill_all_local_variables. | 720 | Instead, use Fkill_all_local_variables. |
| 719 | 721 | ||
| 720 | If PERMANENT_TOO is 1, then we reset permanent built-in | 722 | If PERMANENT_TOO is 1, then we reset permanent |
| 721 | buffer-local variables. If PERMANENT_TOO is 0, | 723 | buffer-local variables. If PERMANENT_TOO is 0, |
| 722 | we preserve those. */ | 724 | we preserve those. */ |
| 723 | 725 | ||
| @@ -755,7 +757,23 @@ reset_buffer_local_variables (b, permanent_too) | |||
| 755 | #endif | 757 | #endif |
| 756 | 758 | ||
| 757 | /* Reset all (or most) per-buffer variables to their defaults. */ | 759 | /* Reset all (or most) per-buffer variables to their defaults. */ |
| 758 | b->local_var_alist = Qnil; | 760 | if (permanent_too) |
| 761 | b->local_var_alist = Qnil; | ||
| 762 | else | ||
| 763 | { | ||
| 764 | Lisp_Object tmp, last = Qnil; | ||
| 765 | for (tmp = b->local_var_alist; CONSP (tmp); tmp = XCDR (tmp)) | ||
| 766 | if (CONSP (XCAR (tmp)) | ||
| 767 | && SYMBOLP (XCAR (XCAR (tmp))) | ||
| 768 | && !NILP (Fget (XCAR (XCAR (tmp)), Qpermanent_local))) | ||
| 769 | /* If permanent-local, keep it. */ | ||
| 770 | last = tmp; | ||
| 771 | else if (NILP (last)) | ||
| 772 | b->local_var_alist = XCDR (tmp); | ||
| 773 | else | ||
| 774 | XSETCDR (last, XCDR (tmp)); | ||
| 775 | } | ||
| 776 | |||
| 759 | for (i = 0; i < last_per_buffer_idx; ++i) | 777 | for (i = 0; i < last_per_buffer_idx; ++i) |
| 760 | if (permanent_too || buffer_permanent_local_flags[i] == 0) | 778 | if (permanent_too || buffer_permanent_local_flags[i] == 0) |
| 761 | SET_PER_BUFFER_VALUE_P (b, i, 0); | 779 | SET_PER_BUFFER_VALUE_P (b, i, 0); |
| @@ -1170,7 +1188,9 @@ buffer as BUFFER. */) | |||
| 1170 | } | 1188 | } |
| 1171 | 1189 | ||
| 1172 | DEFUN ("rename-buffer", Frename_buffer, Srename_buffer, 1, 2, | 1190 | DEFUN ("rename-buffer", Frename_buffer, Srename_buffer, 1, 2, |
| 1173 | "sRename buffer (to new name): \nP", | 1191 | "(list (read-string \"Rename buffer (to new name): \" \ |
| 1192 | nil 'buffer-name-history (buffer-name (current-buffer))) \ | ||
| 1193 | current-prefix-arg)", | ||
| 1174 | doc: /* Change current buffer's name to NEWNAME (a string). | 1194 | doc: /* Change current buffer's name to NEWNAME (a string). |
| 1175 | If second arg UNIQUE is nil or omitted, it is an error if a | 1195 | If second arg UNIQUE is nil or omitted, it is an error if a |
| 1176 | buffer named NEWNAME already exists. | 1196 | buffer named NEWNAME already exists. |
| @@ -2467,14 +2487,10 @@ The first thing this function does is run | |||
| 2467 | the normal hook `change-major-mode-hook'. */) | 2487 | the normal hook `change-major-mode-hook'. */) |
| 2468 | () | 2488 | () |
| 2469 | { | 2489 | { |
| 2470 | register Lisp_Object alist, sym, tem; | ||
| 2471 | Lisp_Object oalist; | ||
| 2472 | |||
| 2473 | if (!NILP (Vrun_hooks)) | 2490 | if (!NILP (Vrun_hooks)) |
| 2474 | call1 (Vrun_hooks, Qchange_major_mode_hook); | 2491 | call1 (Vrun_hooks, Qchange_major_mode_hook); |
| 2475 | oalist = current_buffer->local_var_alist; | ||
| 2476 | 2492 | ||
| 2477 | /* Make sure none of the bindings in oalist | 2493 | /* Make sure none of the bindings in local_var_alist |
| 2478 | remain swapped in, in their symbols. */ | 2494 | remain swapped in, in their symbols. */ |
| 2479 | 2495 | ||
| 2480 | swap_out_buffer_local_variables (current_buffer); | 2496 | swap_out_buffer_local_variables (current_buffer); |
| @@ -2483,20 +2499,6 @@ the normal hook `change-major-mode-hook'. */) | |||
| 2483 | 2499 | ||
| 2484 | reset_buffer_local_variables (current_buffer, 0); | 2500 | reset_buffer_local_variables (current_buffer, 0); |
| 2485 | 2501 | ||
| 2486 | /* Any which are supposed to be permanent, | ||
| 2487 | make local again, with the same values they had. */ | ||
| 2488 | |||
| 2489 | for (alist = oalist; CONSP (alist); alist = XCDR (alist)) | ||
| 2490 | { | ||
| 2491 | sym = XCAR (XCAR (alist)); | ||
| 2492 | tem = Fget (sym, Qpermanent_local); | ||
| 2493 | if (! NILP (tem)) | ||
| 2494 | { | ||
| 2495 | Fmake_local_variable (sym); | ||
| 2496 | Fset (sym, XCDR (XCAR (alist))); | ||
| 2497 | } | ||
| 2498 | } | ||
| 2499 | |||
| 2500 | /* Force mode-line redisplay. Useful here because all major mode | 2502 | /* Force mode-line redisplay. Useful here because all major mode |
| 2501 | commands call this function. */ | 2503 | commands call this function. */ |
| 2502 | update_mode_lines++; | 2504 | update_mode_lines++; |