comparison src/buffer.c @ 91239:2fcaae6177a5

Merge from emacs--devo--0 Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-300
author Miles Bader <miles@gnu.org>
date Sun, 16 Dec 2007 05:08:49 +0000
parents 53108e6cea98 40dcde0eb331
children 606f2d163a64
comparison
equal deleted inserted replaced
91238:5cf14a2107b5 91239:2fcaae6177a5
105 105
106 /* Number of per-buffer variables used. */ 106 /* Number of per-buffer variables used. */
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,
119 to prevent lossage due to user rplac'ing this alist or its elements. */ 121 to prevent lossage due to user rplac'ing this alist or its elements. */
120 Lisp_Object Vbuffer_alist; 122 Lisp_Object Vbuffer_alist;
715 /* Reset buffer B's local variables info. 717 /* Reset buffer B's local variables info.
716 Don't use this on a buffer that has already been in use; 718 Don't use this on a buffer that has already been in use;
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
724 static void 726 static void
725 reset_buffer_local_variables (b, permanent_too) 727 reset_buffer_local_variables (b, permanent_too)
753 #ifndef DOS_NT 755 #ifndef DOS_NT
754 b->buffer_file_type = Qnil; 756 b->buffer_file_type = Qnil;
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);
762 780
763 /* For each slot that has a default value, 781 /* For each slot that has a default value,
1168 1186
1169 return make_number (BUF_CHARS_MODIFF (buf)); 1187 return make_number (BUF_CHARS_MODIFF (buf));
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.
1177 If UNIQUE is non-nil, come up with a new name using 1197 If UNIQUE is non-nil, come up with a new name using
1178 `generate-new-buffer-name'. 1198 `generate-new-buffer-name'.
2465 2485
2466 The first thing this function does is run 2486 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; 2492
2476 2493 /* Make sure none of the bindings in local_var_alist
2477 /* Make sure none of the bindings in oalist
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);
2481 2497
2482 /* Actually eliminate all local bindings of this buffer. */ 2498 /* Actually eliminate all local bindings of this buffer. */
2483 2499
2484 reset_buffer_local_variables (current_buffer, 0); 2500 reset_buffer_local_variables (current_buffer, 0);
2485
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 2501
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++;
2503 2505