Recursive edit helps when you want to break out of the current command that you’re currently doing and temporarily pursue something else, with the ability to snap back to where you were before.
For example, when replacing some text with `
M-%’ or `
M-C-%’ you can replace and edit the matches with
‘C-w’ or just edit with
‘C-r’ to touch up some of the entries you are replacing along the way when they are a special case. When you’re done you punch
‘C-M-c’ and you snap back into
‘query-replace-regexp’. You can even change buffers or visit other files – almost anything.
While saving buffers with
‘C-x s’, type
‘C-r’ to view the current file in ViewMode.
The EmacsManual says:
‘query-replace’, you may type a command that enters the debugger. This begins a recursive editing level for the debugger, within the recursive editing level for
‘C-r’. Mode lines display a pair of square brackets for each recursive editing level currently in progress.
When are you in recursive edit?:
‘abort-recursive-edit’) to do this.
And the most important thing it says for EmacsLisp programmers:
Similarly, the ElispManual says this:
‘e’command in Rmail uses this technique.) Or, if you wish to give the user different text to edit “recursively,” create and select a new buffer in a special mode. In this mode, define a command to complete the processing and go back to the previous buffer. (The
‘m’command in Rmail does this.)