bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#23785: Emacs 25: 'Undo' overdoes things.


From: Phillip Lord
Subject: bug#23785: Emacs 25: 'Undo' overdoes things.
Date: Tue, 21 Jun 2016 23:08:59 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.95 (gnu/linux)

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

>> +      /*
>> +        Temporarily enable the undo-buffer to ensure that the change
>> +        is marked as an undoable one. Bug #23785.
>> +       */
>> +      bset_undo_list(current_buffer,Qnil);
>
> Additionally to Eli's remark about the shape of your comments, please
> also put spaces before open parens and after commas.

Oh, dear, I took Eli's okay and commited. I always was over
enthusiastic. I think I better revert.


>
>>        insert_from_buffer (XBUFFER (conversion_buffer),
>>                        same_at_start_charpos, inserted_chars, 0);
>> +      bset_undo_list(current_buffer,Qt);
>
> Instead of two bset_undo_list, you could use a single specbind since the
> above code is almost immediately followed by unbind_to.


I tried that

      specbind (intern("buffer-undo-list"), Qnil);


> But more seriously, I'm wondering: where is undo-list set to t (and
> hence causing the problem we're seeing)?
> Searching for "undo" in that function gives m the impression that
> undo-0list won't be set to t during the call to insert_from_buffer.
> What am I missing?

It's set in several places to Qt, then restored at the end here.

      if (!empty_undo_list_p)
        {
          bset_undo_list (current_buffer, old_undo);
          if (CONSP (old_undo) && inserted != old_inserted)
            {
              /* Adjust the last undo record for the size change during
                 the format conversion.  */
              Lisp_Object tem = XCAR (old_undo);
              if (CONSP (tem) && INTEGERP (XCAR (tem))
                  && INTEGERP (XCDR (tem))
                  && XFASTINT (XCDR (tem)) == PT + old_inserted)
                XSETCDR (tem, make_number (PT + inserted));
            }
        }

At least that was my theory; I tested it by adding print statements to
run_undoable_change which running, but returning before the call0.

run_undoable_change (void)
{
  if (EQ (BVAR (current_buffer, undo_list), Qt))
    return;

  call0 (Qundo_auto__undoable_change);
}

The code is convoluted enough, though, that I am worried that I may have
got this wrong.


Anyway, I've just testing emacs-25 after my change, the patch seems to
be doing very bad things -- i.e. leaving buffer-undo-list as Qt. So, I
think I really sure revert, then worry about it tomorrow.

Phil





reply via email to

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