In particular, I am using undo-tree-undo.

When I type a few words in a line, and undo, all those words disappear. Same thing happens when I type a function name and screw up a couple of symbols in the end - undo eats up the whole line.

Is there a way to adjust how eager undo is?

(Similar question for native undo: fine-grained undo)

  • duplicate? the other thread is for native undo, this one is for undo-tree as explained in the comments of the answer below Commented Feb 16, 2019 at 9:05

1 Answer 1


I like to do two things with undo. I turn off the amalgamation stuff (which by doing so permits undo one keystroke at a time); and, I get rid of the timer (because timers affect performance and drive me absolutely bonkers, unless they are idle-timers).

(when (timerp undo-auto-current-boundary-timer)
  (cancel-timer undo-auto-current-boundary-timer))

(fset 'undo-auto--undoable-change
      (lambda () (add-to-list 'undo-auto--undoably-changed-buffers (current-buffer))))

(fset 'undo-auto-amalgamate 'ignore)

Alternatively, you can modify the function undo-auto-amalgamate (which is hard coded at 20) and set it to a lesser/greater amount.

  • Why did you copy your answer from emacs.stackexchange.com/questions/47341/fine-grained-undo/… rather than close the question as a duplicate? Do you think that there are potential answers to this question that wouldn't work for the earlier question? Commented Feb 13, 2019 at 18:10
  • @Gilles -- I am of the opinion that most people who use undo-tree would have no way of knowing that the answer applies equally to native undo (without undo-tree) and also to undo-tree. undo-tree is a complex library. I previously spent a couple hundred hours (probably more) creating a fork of undo-tree (with some assistance of a few forum participants who provided certain functions and guidance). Perhaps the only people who would know the answers are equally applicable are me, Stefan, Dr. Cubitt, Tobias, .... [and anyone who reads this comment :) ].
    – lawlist
    Commented Feb 13, 2019 at 18:19
  • I see. What works for native undo might not work for undo-tree and vice versa. This does make sense, thanks. Commented Feb 13, 2019 at 18:27
  • Nice point on timers! I do see some results. When I delete a word after typing or issue some other command, undo catches up on that. But typing a dozen words and undoing (even on multiple lines) the whole line is removed by undoing. A couple of words would arguably be nicer. Modifying last-amalgamating-count to 2 or 50 from 20 seems of no help on this one too, unfortunately. Any ideas? Commented Feb 13, 2019 at 18:28
  • 1
    EX: (1) Launch Emacs 26.1 without any user-configuration (i.e., no .emacs, no init.el) aka emacs -Q. (2) M-x list-packages; (3) find the undo-tree package and install it; (4) type M-x find-function to locate and copy undo-auto-amalgamate; (5) switch to an empty *scratch* buffer and paste the copied function undo-auto-amalgamate; (6) change the number 20 to 3; (7) type M-x eval-buffer; (8) type M-x undo-tree-mode. (9) Place the cursor at the end of the copied function and hold down the backspace key for a few seconds. (10) C-/ and watch the undo a few at at time.
    – lawlist
    Commented Feb 13, 2019 at 19:08

Not the answer you're looking for? Browse other questions tagged or ask your own question.