aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim F. Storm2006-08-22 09:25:59 +0000
committerKim F. Storm2006-08-22 09:25:59 +0000
commit38babc072d6104b73f5a93a736edd0f232f4a10e (patch)
tree1bf614d9cf9c69814aae025b404b09ab8fc87040
parent1867217a61f67cb32ea9e1808daa313b9fad21df (diff)
downloademacs-38babc072d6104b73f5a93a736edd0f232f4a10e.tar.gz
emacs-38babc072d6104b73f5a93a736edd0f232f4a10e.zip
2006-08-22 Stefan Monnier <monnier@iro.umontreal.ca>
(Fset_buffer_multibyte): Record proper undo entry.
-rw-r--r--src/buffer.c26
1 files changed, 19 insertions, 7 deletions
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. */)
2115{ 2115{
2116 struct Lisp_Marker *tail, *markers; 2116 struct Lisp_Marker *tail, *markers;
2117 struct buffer *other; 2117 struct buffer *other;
2118 int undo_enabled_p = !EQ (current_buffer->undo_list, Qt);
2119 int begv, zv; 2118 int begv, zv;
2120 int narrowed = (BEG != BEGV || Z != ZV); 2119 int narrowed = (BEG != BEGV || Z != ZV);
2121 int modified_p = !NILP (Fbuffer_modified_p (Qnil)); 2120 int modified_p = !NILP (Fbuffer_modified_p (Qnil));
2121 Lisp_Object old_undo = current_buffer->undo_list;
2122 struct gcpro gcpro1;
2122 2123
2123 if (current_buffer->base_buffer) 2124 if (current_buffer->base_buffer)
2124 error ("Cannot do `set-buffer-multibyte' on an indirect buffer"); 2125 error ("Cannot do `set-buffer-multibyte' on an indirect buffer");
@@ -2127,10 +2128,11 @@ current buffer is cleared. */)
2127 if (NILP (flag) == NILP (current_buffer->enable_multibyte_characters)) 2128 if (NILP (flag) == NILP (current_buffer->enable_multibyte_characters))
2128 return flag; 2129 return flag;
2129 2130
2130 /* It would be better to update the list, 2131 GCPRO1 (old_undo);
2131 but this is good enough for now. */ 2132
2132 if (undo_enabled_p) 2133 /* Don't record these buffer changes. We will put a special undo entry
2133 current_buffer->undo_list = Qt; 2134 instead. */
2135 current_buffer->undo_list = Qt;
2134 2136
2135 /* If the cached position is for this buffer, clear it out. */ 2137 /* If the cached position is for this buffer, clear it out. */
2136 clear_charpos_cache (current_buffer); 2138 clear_charpos_cache (current_buffer);
@@ -2330,8 +2332,18 @@ current buffer is cleared. */)
2330 set_intervals_multibyte (1); 2332 set_intervals_multibyte (1);
2331 } 2333 }
2332 2334
2333 if (undo_enabled_p) 2335 if (!EQ (old_undo, Qt))
2334 current_buffer->undo_list = Qnil; 2336 {
2337 /* Represent all the above changes by a special undo entry. */
2338 extern Lisp_Object Qapply;
2339 Lisp_Object args[3];
2340 args[0] = Qapply;
2341 args[1] = intern ("set-buffer-multibyte");
2342 args[2] = NILP (flag) ? Qt : Qnil;
2343 current_buffer->undo_list = Fcons (Flist (3, args), old_undo);
2344 }
2345
2346 UNGCPRO;
2335 2347
2336 /* Changing the multibyteness of a buffer means that all windows 2348 /* Changing the multibyteness of a buffer means that all windows
2337 showing that buffer must be updated thoroughly. */ 2349 showing that buffer must be updated thoroughly. */