emacs-devel
[Top][All Lists]
Advanced

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

Re: disabling undo boundaries


From: Phillip Lord
Subject: Re: disabling undo boundaries
Date: Tue, 12 May 2015 21:59:59 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Stefan Monnier <address@hidden> writes:

>>> Then maybe you could try a hack like:
>>> 
>>> (with-current-buffer "*scratch*"
>>>   <doyourthing>)
>>> (let ((buffer-undo-list))
>>>   (undo-boundary))           ; Set last_undo_buffer.
>> It doesn't unfortunately.
>
> Oh, indeed when buffer-undo-list, undo-boundary is a no-op, so you need
>
>    (with-current-buffer "*scratch*"
>      <doyourthing>)
>    (let ((buffer-undo-list '("")))
>      (undo-boundary))           ; Set last_undo_buffer.

My fault for not being clear. AFAICT, undo-boundary does not set
last_undo_buffer at all. I can't directly test this because I can't get
to last_undo_buffer from lisp, but here is my test code.

#+BEGIN_SRC emacs-lisp
  (defvar-local fix-test-on nil)
  (defvar fix-test-fudge t)
  (defun fix-test-after-change-function (&rest _)
      (when fix-test-on
        (with-current-buffer
            (get-buffer "*scratch*")
          (insert "a"))
        (when fix-test-fudge
          (let ((buffer-undo-list '("")))
            (undo-boundary)))))

  (add-hook 'after-change-functions 'fix-test-after-change-function)
#+END_SRC

Setting `fix-test-on' to t still affects undo in the current-buffer.


>> It is, and one that has been in Emacs for a long time.  How wedded to
>> keeping it are you? Would it be possible to optionalize?
>
> Not sure,

Well I have a fork running without it (with some brutal commenting out),
so I'll try running that as my daily emacs, and see if it crashes and
how it behaves.

I'm still trying to understand the reason behind the logic in the first
place; unfortunately, the code seems to predate the earliest VC records.

Thanks for the feedback, it's been as helpful as always.

Phil



reply via email to

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