From 43ed3b8da0c563a5fec8708cada2ee39411062ec Mon Sep 17 00:00:00 2001 From: Chong Yidong Date: Sun, 6 Aug 2006 14:22:24 +0000 Subject: * buffer.c (Vchange_major_mode_hook, Qchange_major_mode_hook): New vars. (Fkill_all_local_variables): Use it. (syms_of_buffer): Defvar it. --- src/buffer.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/buffer.c') diff --git a/src/buffer.c b/src/buffer.c index fcb842de83c..3502afc9bf0 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -146,6 +146,9 @@ Lisp_Object Vinhibit_read_only; Lisp_Object Vkill_buffer_query_functions; Lisp_Object Qkill_buffer_query_functions; +/* Hook run before changing a major mode. */ +Lisp_Object Vchange_major_mode_hook, Qchange_major_mode_hook; + /* List of functions to call before changing an unmodified buffer. */ Lisp_Object Vfirst_change_hook; @@ -2386,7 +2389,7 @@ the normal hook `change-major-mode-hook'. */) Lisp_Object oalist; if (!NILP (Vrun_hooks)) - call1 (Vrun_hooks, intern ("change-major-mode-hook")); + call1 (Vrun_hooks, Qchange_major_mode_hook); oalist = current_buffer->local_var_alist; /* Make sure none of the bindings in oalist @@ -5998,6 +6001,13 @@ t means to use hollow box cursor. See `cursor-type' for other values. */); doc: /* List of functions called with no args to query before killing a buffer. */); Vkill_buffer_query_functions = Qnil; + DEFVAR_LISP ("change-major-mode-hook", &Vchange_major_mode_hook, + doc: /* Normal hook run before changing the major mode of a buffer. +The function `kill-all-local-variables' runs this before doing anything else. */); + Vchange_major_mode_hook = Qnil; + Qchange_major_mode_hook = intern ("change-major-mode-hook"); + staticpro (&Qchange_major_mode_hook); + defsubr (&Sbuffer_live_p); defsubr (&Sbuffer_list); defsubr (&Sget_buffer); -- cgit v1.2.3 From 38babc072d6104b73f5a93a736edd0f232f4a10e Mon Sep 17 00:00:00 2001 From: "Kim F. Storm" Date: Tue, 22 Aug 2006 09:25:59 +0000 Subject: 2006-08-22 Stefan Monnier (Fset_buffer_multibyte): Record proper undo entry. --- src/buffer.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'src/buffer.c') diff --git a/src/buffer.c b/src/buffer.c index 3502afc9bf0..07d0f676aa2 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -2115,10 +2115,11 @@ current buffer is cleared. */) { struct Lisp_Marker *tail, *markers; struct buffer *other; - int undo_enabled_p = !EQ (current_buffer->undo_list, Qt); int begv, zv; int narrowed = (BEG != BEGV || Z != ZV); int modified_p = !NILP (Fbuffer_modified_p (Qnil)); + Lisp_Object old_undo = current_buffer->undo_list; + struct gcpro gcpro1; if (current_buffer->base_buffer) error ("Cannot do `set-buffer-multibyte' on an indirect buffer"); @@ -2127,10 +2128,11 @@ current buffer is cleared. */) if (NILP (flag) == NILP (current_buffer->enable_multibyte_characters)) return flag; - /* It would be better to update the list, - but this is good enough for now. */ - if (undo_enabled_p) - current_buffer->undo_list = Qt; + GCPRO1 (old_undo); + + /* Don't record these buffer changes. We will put a special undo entry + instead. */ + current_buffer->undo_list = Qt; /* If the cached position is for this buffer, clear it out. */ clear_charpos_cache (current_buffer); @@ -2330,8 +2332,18 @@ current buffer is cleared. */) set_intervals_multibyte (1); } - if (undo_enabled_p) - current_buffer->undo_list = Qnil; + if (!EQ (old_undo, Qt)) + { + /* Represent all the above changes by a special undo entry. */ + extern Lisp_Object Qapply; + Lisp_Object args[3]; + args[0] = Qapply; + args[1] = intern ("set-buffer-multibyte"); + args[2] = NILP (flag) ? Qt : Qnil; + current_buffer->undo_list = Fcons (Flist (3, args), old_undo); + } + + UNGCPRO; /* Changing the multibyteness of a buffer means that all windows showing that buffer must be updated thoroughly. */ -- cgit v1.2.3 From fab45703d34ca5c8c0adea32a1731bc8b73d77db Mon Sep 17 00:00:00 2001 From: Nick Roberts Date: Thu, 24 Aug 2006 20:40:53 +0000 Subject: (Fswitch_to_buffer): Move buffer to front of buffer-alist if necessary. --- src/buffer.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/buffer.c') diff --git a/src/buffer.c b/src/buffer.c index 07d0f676aa2..f6c45852b51 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -1684,9 +1684,13 @@ the window-buffer correspondences. */) char *err; if (EQ (buffer, Fwindow_buffer (selected_window))) - /* Basically a NOP. Avoid signalling an error if the selected window - is dedicated, or a minibuffer, ... */ - return Fset_buffer (buffer); + { + if (NILP (norecord) && !EQ (buffer, XCDR (XCAR (Vbuffer_alist)))) + record_buffer (buffer); + /* Basically a NOP. Avoid signalling an error if the selected window + is dedicated, or a minibuffer, ... */ + return Fset_buffer (buffer); + } err = no_switch_window (selected_window); if (err) error (err); -- cgit v1.2.3 From 611ac52147a4682f0c8befc8483dc095966d3fbf Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Fri, 25 Aug 2006 21:10:26 +0000 Subject: (Fswitch_to_buffer): Fix previous change. --- src/buffer.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/buffer.c') diff --git a/src/buffer.c b/src/buffer.c index f6c45852b51..81ea51b357a 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -1685,10 +1685,15 @@ the window-buffer correspondences. */) if (EQ (buffer, Fwindow_buffer (selected_window))) { - if (NILP (norecord) && !EQ (buffer, XCDR (XCAR (Vbuffer_alist)))) + /* Basically a NOP. Avoid signalling an error in the case where + the selected window is dedicated, or a minibuffer. */ + + /* But do put this buffer at the front of the buffer list, + unless that has been inhibited. Note that even if + BUFFER is at the front of the main buffer-list already, + we still want to move it to the front of the frame's buffer list. */ + if (NILP (norecord)) record_buffer (buffer); - /* Basically a NOP. Avoid signalling an error if the selected window - is dedicated, or a minibuffer, ... */ return Fset_buffer (buffer); } -- cgit v1.2.3 From 8929fd8784f3029494d04fef6896247385c9d6c0 Mon Sep 17 00:00:00 2001 From: "Kim F. Storm" Date: Fri, 25 Aug 2006 23:33:44 +0000 Subject: (Fset_buffer_multibyte): Simplify; use list3. --- src/buffer.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/buffer.c') diff --git a/src/buffer.c b/src/buffer.c index 81ea51b357a..863b217d2b4 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -2345,11 +2345,10 @@ current buffer is cleared. */) { /* Represent all the above changes by a special undo entry. */ extern Lisp_Object Qapply; - Lisp_Object args[3]; - args[0] = Qapply; - args[1] = intern ("set-buffer-multibyte"); - args[2] = NILP (flag) ? Qt : Qnil; - current_buffer->undo_list = Fcons (Flist (3, args), old_undo); + current_buffer->undo_list = Fcons (list3 (Qapply, + intern ("set-buffer-multibyte"), + NILP (flag) ? Qt : Qnil), + old_undo); } UNGCPRO; -- cgit v1.2.3