How can I have single keystroke undo using Doom Emacs with Emacs 27.2? I have already tried multiple suggestions on this site, so far none work. Perhaps Doom Emacs is the problem, or maybe it's that I'm using Emacs 27.2. Is there a new solution someone can share?
1 Answer
It is unknown why the O.P. is experiencing problems. The following method of installation and usage of a prior answer in a related thread appears to work correctly without any issues.
STEP #1: Install a fresh version of Doom. In my case, I renamed the existing ~/.emacs.d
to preserve the contents and to enable git
to create a new ~/.emacs.d
in which to install Doom. In a terminal, run the command:
git clone --depth 1 https://github.com/hlissner/doom-emacs ~/.emacs.d
STEP #2: In the terminal, navigate with cd
over to ~/.emacs.d/bin
and run the command:
./doom install
Be patient while many packages are downloaded and installed.
STEP #3: I chose y
when presented with the prompt/question:
Download and install all-the-icon's fonts? (y or n)
STEP #4: In the terminal, run the command:
./doom sync
STEP #5: Open up ~/.emacs.d/init.el
, navigate to the bottom of the file, and insert the following snippet from the answer to the related question https://emacs.stackexchange.com/a/47349/2287
(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)
Save the file.
STEP #6: Open or restart a recent version of Emacs, e.g., Emacs 27.2.
STEP #7: Open a new buffer. I am unfamiliar with vi
and evil
, and M-x
seems to be disabled, so I used: M-:
to access eval-expression
. I typed (find-file "FOO")
. I pressed the letter "i
" to enable insert-mode
to insert text into the current buffer. I typed the word: Hello
. I used the keyboard shortcut to interactively call undo-fu-only-undo
, which was bound by default on OSX El Capitan to s-z
. Emacs undoes one keystroke at a time.
INSTALL NOTES: In my case, OSX El Capitan comes with a pre-installed outdated version of Emacs at /usr/bin/emacs
. It was necessary to modify the ~/.emacs.d/bin/doom
script to use a current version of Emacs, or perhaps create an alias so that the script calls to $EMACS
find a recent version. I also had to devise a method so that the files used to build Doom could find a more recent version of git
. Finally, the file +azerty.el
was uncooperative with the version of wgrep
that I used when trying to modify the call to "git"
-- I'm not sure why the file was uncooperative, but I went ahead and deleted the extra ^M
carriage returns and modified the line with "git"
to use an absolute path. However, I do not know whether that file is used when building Doom.
-
s-z
was the solution. All the Doom keybinding docs (what few correct ones there are) I've read up until now said to useu
for undo. Thanks!– gdonaldCommented Mar 8, 2022 at 13:40