Mercurial > emacs
comparison src/buffer.c @ 72486:c5d047643872
2006-08-22 Stefan Monnier <monnier@iro.umontreal.ca>
(Fset_buffer_multibyte): Record proper undo entry.
| author | Kim F. Storm <storm@cua.dk> |
|---|---|
| date | Tue, 22 Aug 2006 09:25:59 +0000 |
| parents | e97bfa736263 |
| children | 6ccb18aa8a5d |
comparison
equal
deleted
inserted
replaced
| 72485:030d7ce12631 | 72486:c5d047643872 |
|---|---|
| 2113 (flag) | 2113 (flag) |
| 2114 Lisp_Object flag; | 2114 Lisp_Object flag; |
| 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"); |
| 2125 | 2126 |
| 2126 /* Do nothing if nothing actually changes. */ | 2127 /* Do nothing if nothing actually changes. */ |
| 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); |
| 2137 | 2139 |
| 2138 if (NILP (flag)) | 2140 if (NILP (flag)) |
| 2328 /* Do this last, so it can calculate the new correspondences | 2330 /* Do this last, so it can calculate the new correspondences |
| 2329 between chars and bytes. */ | 2331 between chars and bytes. */ |
| 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. */ |
| 2338 current_buffer->prevent_redisplay_optimizations_p = 1; | 2350 current_buffer->prevent_redisplay_optimizations_p = 1; |
| 2339 ++windows_or_buffers_changed; | 2351 ++windows_or_buffers_changed; |
