emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Changing of line format and undo


From: Stefan Monnier
Subject: Re: Changing of line format and undo
Date: Mon, 21 Aug 2006 12:17:40 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

> RMS agreed to install the following change in Emacs 22.

Oh, did he?  I must have missed it.  If you want to install it, then please
go ahead (I'm on the road right now).  Otherwise I'll get to it later.
Thanks,


        Stefan


> Stefan Monnier <address@hidden> writes:

>>> Thanks, you are right ;-) Now I see what Eli meant. I still believe that
>>> everything that can result in changing an external file should go into the
>>> undo history but this is really a corner case of course.
>> 
>> You can change C-x RET f to do what you want by having it add (manually in
>> elisp) an `apply' entry to buufer-undo-list.
>> 
>> E.g. I've changed my set-buffer-multibyte to do that (waiting for post-22
>> to commit it).
>> 
>> 
>> Stefan
>> 
>> 
>> --- orig/src/buffer.c
>> +++ mod/src/buffer.c
>> @@ -2112,10 +2100,11 @@
>> {
>> 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");
>> @@ -2124,10 +2113,11 @@
>> 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);
>> @@ -2327,8 +2317,18 @@
>> 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] = Qset_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.  */

> -- 
> Kim F. Storm <address@hidden> http://www.cua.dk




reply via email to

[Prev in Thread] Current Thread [Next in Thread]