Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [undo]

The tag has no usage guidance.

1
vote
1answer
21 views

Is it possible to group series of changes under single undo step?

I am writing template insert function for a file format that needs to keep header counter updated. I'd like that undo operation removes not only in place template changes but also corresponding ...
0
votes
1answer
53 views

Why isn't the jch's “with-undo-collapse” macro an emacs built-in yet?

I wondered why the jch's with-undo-collapse macro (or something like that) isn't an emacs built-in yet. Is it safe enough? Is there a built-in alternative? I mean something that can be applied like ...
4
votes
1answer
52 views

change how much undo-tree-undo undoes [duplicate]

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 ...
3
votes
1answer
327 views

Remove unsaved text in Emacs

Is there a way to remove unsaved text and get back the latest saved state of a file in Emacs without using undo? Like this: | a - write some text to save | b - save the file | c - add some text to ...
4
votes
1answer
144 views

fine-grained undo

How to make M-x undo more fine-grained or sensitive? Example: say, I wrote: foo (bar baz) () then I M-x undo and receive: foo (bar but what I want to get after this undo is: foo (bar baz)
3
votes
1answer
67 views

Check if current user undoing/redoing?

Is there a way so that the Emacs are able to tell if the current user is undoing/redoing in the current buffer? Here is the task I want to accomplish, I have add a hook to after-change-function, it ...
0
votes
0answers
12 views

how to undo a sequence of deletes in different directions as a unit?

Emacs will undo sequences of deletes as a unit, provided that they are all the same kind of delete. Is there a way to configure Emacs so that sequences of delete in alternating directions are ...
2
votes
1answer
47 views

Problem redoing with yasnippet

I have had a problem with undoing lately, which seems rather dangerous and has almost lost me work. At first I thought it was due to undo-tree, so I deactivated that. But it persists and now I ...
0
votes
1answer
32 views

Is quiting arbitrary mode possible?

How to exit arbitrary mode x, as it seams for my particular case undo-tree-mode there is no undo-tree-mode related option for undoing it, it there a general solution?
2
votes
0answers
27 views

How to prevent undo from operating on invisible text/regions?

Q: how can I prevent undos of invisible text? I use org-mode and outline-minor-mode in virtually every buffer, and leave text folded (invisible) unless I'm explicitly working on it. Sometimes I hide ...
1
vote
0answers
36 views

How do you create a custom undo?

I have a package that creates overlays as annotations. Part of the functionality is to delete annotations too. It turns out neither of these seems to be undoable. I.e. if you add an overlay to text, ...
5
votes
2answers
121 views

atomic undo blocks [duplicate]

Is it possible to wrap an arbitrary series of operations such that when a single undo command is issued, all of the wrapped operations are undone at once, rather than requiring multiple undos to undo ...
2
votes
1answer
1k views

redo (ctrl+y) undo

I normally undo with ctrl+_ with other editors there is a redo operation normally associated with ctrl+y. is there an emacs equivalent? In general what is the best way to handle an "undo tree"?
1
vote
1answer
59 views

Replacement in loop as a single undo item in buffer-undo-list?

I have this loop: (catch 'QUIT (while (search-forward-regexp "\\([^\n\\]\\(?:\\\\\\\\\\)*\\|^\\(?:\\\\\\\\\\)+\\)%.*\n" nil t) (save-excursion (let ((b (make-...
2
votes
2answers
316 views

Undo region spacemacs

I really appreciate the undo in region command in standard emacs, where you can just mark a region and only changes made in that region are undone. This doesn't seem to work in the default spacemacs ...
1
vote
1answer
38 views

Cleaning the buffer-undo-list of unwanted entries

When multiple-cursors is deactivated, I would like to remove from the buffer-undo-list all entries that look like this: (apply activate-cursor-for-undo 40) (apply deactivate-cursor-after-undo 38) ...
0
votes
3answers
645 views

how can I get Emacs kill-ring to behave like a simple clipboard buffer?

How can I get Emacs to behave the same as other programs for copy/paste (i.e. OpenOffice, Microsoft Word, etc.)? I want to simplify the kill-ring so that it behaves like a simple clipboard. I find it ...
0
votes
2answers
368 views

How to reset undo history?

I often did undo too much, then redo it. I noticed I have default undo position in my mind. I think C-x C-s is helpful but not enough, because it just indicate modified or not, so the buffer is still ...
6
votes
1answer
78 views

undo-tree output like git log

I just discovered undo-tree-mode and it's amazing. My use case is finding changes that I've made before so that I can re-apply them. However I'm having difficulty finding the changes I've made. Is ...
11
votes
2answers
1k views

Possible not to use undo-tree in evil mode?

Every so often I run into bugs in undo-tree, where I can't redo, with the following known bug, another report & reddit thread. primitive-undo: Unrecognized entry in undo list undo-tree-canary ...
6
votes
3answers
327 views

How can I implement Vim's `undo line` command in Emacs' evil-mode?

From the Vim User Manual: 02.5: There's a special version of the undo command, the "U" (undo line) command. The undo line command undoes all the changes made on the last line that was edited. ...
0
votes
1answer
138 views

Remap redo to C-S-/

I do not like the standard keybinding to redo so I would like to customise it. How can I remap redo to C-S-/? I am not able to find any solution in internet.
2
votes
1answer
2k views

How to assign the undo command to the Ctrl-z keybinding?

I have added: (global-set-key (kbd "C-z") 'undo) to my ~/.emacs file. But still when I press Ctrl+z nothing is undone even when I've had GNU Emacs open for a while and done several things in my ...
6
votes
1answer
403 views

How to make interactive functions (simply) undoable?

This question refers exclusively to interactive functions that modify the contents of the current buffer. What does one need to do to ensure that a single execution of (undo), right after running the ...
5
votes
0answers
74 views

undo-tree tree manipulation/cherry picking?

Is it possible to cherrypick changes from different branches in undo tree? For example say I make a change call it change1. I then undo, and make a change, call it change2. I then undo, and make a ...
1
vote
0answers
69 views

Is there a package to search in history of changes?

While editing files, time to time I regret deleting some redundant parts which afterwards become necessary. Let's say you are writing a letter and first you explained your thoughts with redundantly ...
3
votes
1answer
40 views

Is there a way to defer undo when the changes are off-screen?

Let's say I've added some text to some line: some text▊ Then I scroll down a bit, so that the line is out of sight: ▊ When I press undo, I don't want Emacs to delete the line above immediatedly, ...
2
votes
1answer
34 views

Reverting an incomplete set of operations

What is the preferred method of reverting a partially applied set of operations within a function? For example in a function that kills some text, performs some intervening operations, and then yanks ...
4
votes
2answers
98 views

Why does modification in another buffer create undo boundary in current buffer?

I just noticed that modifying another buffer creates an undo barrier in the current. For example: (defun my-test-undo () (interactive) (insert "A") (with-current-buffer (get-buffer-create "FOO"...
4
votes
1answer
60 views

Reverting back a buffer to what it was x minutes ago

This question is inspired by https://stackoverflow.com/a/726942/. I am wondering if it is possible to revert back a buffer to its state of x minutes ago.
4
votes
1answer
2k views

undo tree in spacemacs

Did anyone use undo tree in spacemacs? I configured it in spacemacs (global-undo-tree-mode 1) but it doens't work. how to let it work? It shows the error message of "unrecognized entry in undo ...
3
votes
3answers
721 views

How to undo on ediff A-B changes

Is there a keybind or a way of undoing each of ediff A-B change? I often want to revert the previous modification.
1
vote
2answers
122 views

Undo custom command without moving the point

I would like to have a command that inserts some text at a distance, while keeping the point in place during its own execution and while being undone. To illustrate the point, consider following ...
6
votes
1answer
36 views

In undo history, how to separate abbrev expansion from self-insert?

Very occasionally, hit SPC during regular typing and get an unexpected abbrev expansion. What I usually do in this case is undo (which reverts the expansion and the inserted space) and then manually C-...
16
votes
2answers
477 views

Collapsing undo history

I'm working on an Emacs mode that lets you control Emacs with speech recognition. One of the problems I've ran into is that the way Emacs handles undo doesn't match how you would expect it to work ...
3
votes
2answers
101 views

After (set-buffer-modified-p nil), the first undo command doesn't set the buffer modified flag to true

If I modify a buffer and then save it, the buffer modified flag resets and the subsequent undo commands set the buffer modified flag to true. However if I use (set-buffer-modified-p nil), the flag ...
10
votes
3answers
592 views

How to modify a buffer without undo noticing?

Q: How do I insert/modify text in a buffer without undo noticing? Here's the use case. I have a comment block at the start of every file that, among other things, updates a timestamp for the most ...
2
votes
2answers
958 views

Is CUA Mode good over usual Emacs Cut and yank commands [closed]

Just wanted to capture the advantages of CUA mode over the usual emacs copy and paste commands. One advantage which is quite obvious is it similar to the keybindings which are present in other editors....
5
votes
1answer
196 views

Why is the `buffer-undo-list` excluded from `(buffer-local-variables)`?

I am modifying desktop.el to support restoring the buffer-undo-list, and am push-ing that list at the tail end of the function desktop-buffer-info because the buffer-undo-list is not included in the ...
32
votes
6answers
3k views

How to reopen just killed buffer, like C-S-t in Firefox Browser?

Sometimes I accidentally kill a buffer and want to reopen it, just like C-S-t to undo closed tab in Firefox, but there is no built-in command in Emacs, the defun undo-kill-buffer in http://www....
16
votes
1answer
401 views

Is there a 'local undo' extension for Emacs?

It happens quite often that I want to undo changes locally or line-wise. For example, when I change multiple lines in a source code and I want to revert only one of them, then I have to step through ...