Interestingly enough, there appears to be no built-in function to do that.
The following code works by inserting a unique marker on the buffer-undo-list at the beginning of a collapsible block, and removing all boundaries (nil elements) at the end of a block, then removing the marker. In case something goes wrong, the marker is of the form (apply identity ...
Since @shosti pointed out that Evil considers deviation from Vim behavior as bugs, I filed a bug and one of the authors of Evil added a new possible value for evil-want-fine-undo:
(setq evil-want-fine-undo 'fine)
With this setting, you get new undo units when moving the cursor in insert mode, but replace operations are undone in one step. As far as I can ...
On Vim editing style, naturally:
j and k to navigate through the tree up and down.
h and l to switch branches.
When using Emacs editing style:
n and p to navigate through the tree up and down.
f and b to switch branches.
On both editing styles:
q or C-g to quit and leave in current state.
C-q to abort changes.
Note: Undo-Tree is a very powerful package ...
The author of undo-tree.el, Toby Cubitt, is presently too busy to fix this particular bug. If he has time in the future, he may look into the issue further. The author has indicated that he has difficulty reproducing the error reliably, and was recently unable to reproduce it using the master branch. It only occurs when using undo/redo-in-region. The ...
The following is a prototype implementation of an approximation of what you want.
It exploits the fact that new branches in the undo-tree are added at the left-hand side of the current node.
The key-sequence C-M-_ is bound to undo-tree-walk which walks the right-upper part of the undo tree starting at the current node.
The behavior differs from what you ...
Magit recently gained support for something like this, but the feature is still a bit rough around the edges and has to be enabled explicitly.
A similar feature has existed for a long time - when you move from one commit to another in a log buffer, and another window in the same frame is the repository's revision buffer, then that buffer is refreshed to ...
I want to simplify the kill-ring so that it behaves like a simple clipboard. I find it complex that the kill-ring contains multiple items.
You can completely ignore the fact that the kill ring contains multiple items if you want. If you only ever use yank (C-y) to paste, then you will only ever paste the most recently-killed text.
Unless you actively tell ...
To make these bindings persistent, put them into your init file. For them to be able to redefine the undo-tree keymap, undo-tree has to be active first. This can either be guaranteed by enabling undo-tree first (which only works after the packages have been enabled in the respective after-init-hook or after using package-initialize in your init file) or by ...
You can try this, if you want to remap all keys bound to undo-tree-undo.
(global-set-key [remap undo-tree-undo] 'left-char)
You can also try making your binding in undo-tree-mode-map, assuming that is what is used by undo-tree-mode:
(lambda () (define-key undo-tree-mode-map (kbd "C-/") 'left-char)))
(I'm just ...
The first basic step would be to
(setq pop-up-frames t)
so that display-buffer always makes a new frame.
A lot of further (but more complicated) customizations are described in the "One On One" Emacs project by Drew Adams.
From the various comments so far, it sounds like you are in the process of learning about Emacs (welcome!). There are many things in Emacs that are unlike other editors, and as you go through the tutorials and read about things you might come across concepts like the kill ring that seem confusing and/or unnecessary.
Emacs is endlessly configurable so you ...
To disable undo/redo-in-region as to the library undo-tree, set the variable undo-tree-enable-undo-in-region to nil:
(setq undo-tree-enable-undo-in-region nil)
The doc-string for the variable states:
When non-nil, enable undo-in-region.
When undo-in-region is enabled, undoing or redoing when the
region is active (in `transient-mark-mode') or with a prefix
In a shell window, make a backup of your files (now), including the autosave files.
After backup. You can probably copy the autosave file over the empty file.
However, and this is very important, make a backup, before you start trying to fix it.
Then when all is good (or not), you need to create a backup strategy, for all of your important data.
Special thanks to @Tobias for writing up a function to locate the next/previous timestamp in the undo/redo history: https://emacs.stackexchange.com/a/32415/2287; and, for also writing up a series of functions to copy the undo-tree: https://emacs.stackexchange.com/a/32230/2287.
As some readers may already be aware, forks are accepted by MELPA only in ...
You most certainly want:
(setq undo-tree-history-directory-alist '(("." . "~/.emacs.d/undo")))
The docstring of this variable speaks of an alist aka association list. These are a list of pairs, where a pair is a cons cell. The short-hand syntax for a cons cell is (foo . 1) whereas the short-hand syntax for returning a list as is would be '(...), both ...
(advice-add #'undo-tree :filter-return #'undo-tree-advice-history-save-file-name)
This advises the function undo-tree, whereas the defadvice form advises undo-tree-make-history-save-file-name. The equivalent advice-add would be
(advice-add 'undo-tree-make-history-save-file-name :filter-return #'undo-tree-advice-history-save-file-name)
You solution can be achieved in one of the two ways:
You define your own minor mode whose key-bindings overrides the bindings set by all other minor/major modes.
You set that particular key-binding in that minor/major mode to nil.
These solutions can be implemented in multiple ways and they have been presented in detail in these Emacs SE and SO posts:
Some changes to the undo machinery "recently" broke some hack viper-mode was using to do this kind of collapsing (for the curious, it's used in the following case: when you press ESC to finish an insertion/replacement/edition, Viper wants to collapse the whole change into a single undo step).
To fix it cleanly, we introduced a new function undo-amalgamate-...
Here is the solution I eventually came up with. (Thanks to @phils for optimizations). As far as I can tell, it seems to be working without issues.
(defun nadvice/undo-tree-ignore-text-properties (old-fun &rest args)
(dolist (item buffer-undo-list)
(and (consp item)
(stringp (car item))
(setcar item (substring-no-properties (car ...
The following is a modified version of undo-tree-save-history.
As the code in the first version of your question I don't write to a file but output the undo tree as a string. I hope that is okay.
The most important changes w.r.t. undo-tree-save-history are:
a recursive copy of the undo tree via (copy-tree buffer-undo-tree t) to avoid effects on the ...
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)
undo-tree-mode is a buffer-local minor mode, so M-x undo-tree-mode will toggle it in the current buffer.
Note that if you are in fact using global-undo-tree-mode then that is a global minor mode which controls the buffer-local minor mode in all applicable buffers en-masse, and you would want to use M-x global-undo-tree-mode to toggle that, if you wanted to ...
This is a problem with undo-tree. At the time of this writing there is no workaround nor a fix on the horizon. The last update to the package was August 8, 2013. Apparently no one has a reliable way to even reproduce the problem.
To quote a related SE post:
The author of undo-tree.el, Toby Cubitt, is presently too busy to fix
this particular bug. ...
The commentary at the outset of the undo-tree.el library describes two built-in methods to undo and redo: https://github.com/emacsmirror/undo-tree/blob/master/undo-tree.el#L87
;; C-_ C-/ (`undo-tree-undo')
;; Undo changes.
;; M-_ C-? (`undo-tree-redo')
;; Redo changes.
The mode key map does not follow the normal naming convention, and instead ...
The following code fragment should do what you want:
(cl-remove-if (lambda (x) (and (consp x) (eq (car x) 'apply)
(setq x (cdr x))
(consp x) (memq (car x) '(activate-cursor-for-undo deactivate-cursor-after-undo))
(setq x (cdr x))