diff options
author | Miha Rihtaršič <miha@kamnitnik.top> | 2021-09-20 07:59:29 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2021-09-20 07:59:29 +0200 |
commit | 31ba9bbf6c2d0a265c77de1c068400b750ecf34b (patch) | |
tree | 2ff04f3e3e9ff3b801f463f33c0671586b69475c /lisp/minibuffer.el | |
parent | 995a623594de27d398f0d97fcab9277e37fe29d1 (diff) | |
download | emacs-31ba9bbf6c2d0a265c77de1c068400b750ecf34b.tar.gz |
Refactor minibuffer aborting
* lisp/minibuffer.el (minibuffer-quit-recursive-edit): New optional
argument to specify how many levels of recursion to quit.
* src/eval.c (internal_catch): Remove special handling of 'exit
tag (bug#49700).
* src/minibuf.c (Fabort_minibuffers): Use
minibuffer-quit-recursive-edit to quit multiple levels of minibuffer
recursion.
Diffstat (limited to 'lisp/minibuffer.el')
-rw-r--r-- | lisp/minibuffer.el | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 9668e7c732c..b5c0054a3c2 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -2349,14 +2349,18 @@ that displays the \"*Completions*\" buffer." (add-hook 'minibuffer-exit-hook 'minibuffer-restore-windows) -(defun minibuffer-quit-recursive-edit () - "Quit the command that requested this recursive edit without error. -Like `abort-recursive-edit' without aborting keyboard macro -execution." - ;; See Info node `(elisp)Recursive Editing' for an explanation of - ;; throwing a function to `exit'. - (throw 'exit (lambda () - (signal 'minibuffer-quit nil)))) +(defun minibuffer-quit-recursive-edit (&optional levels) + "Quit the command that requested this recursive edit or minibuffer input. +Do so without terminating keyboard macro recording or execution. +LEVELS specifies the number of nested recursive edits to quit. +If nil, it defaults to 1." + (unless levels + (setq levels 1)) + (if (> levels 1) + ;; See Info node `(elisp)Recursive Editing' for an explanation + ;; of throwing a function to `exit'. + (throw 'exit (lambda () (minibuffer-quit-recursive-edit (1- levels)))) + (throw 'exit (lambda () (signal 'minibuffer-quit nil))))) (defun self-insert-and-exit () "Terminate minibuffer input." |