Allow exit-minibuffer to be called from Lisp code. Fixes bug #46373
* lisp/minibuffer.el (exit-minibuffer): Throw the error "Not in most nested minibuffer" only when the current buffer is a minibuffer (thus the command came directly from a key binding). * doc/lispref/minibuf.texi (Minibuffer Commands): Change the documentation accordingly.
This commit is contained in:
parent
5131e3accc
commit
69d3a6c90f
2 changed files with 4 additions and 2 deletions
|
@ -2393,7 +2393,7 @@ minibuffer.
|
|||
@deffn Command exit-minibuffer
|
||||
This command exits the active minibuffer. It is normally bound to
|
||||
keys in minibuffer local keymaps. The command throws an error if the
|
||||
current buffer is not the active minibuffer.
|
||||
current buffer is a minibuffer, but not the active minibuffer.
|
||||
@end deffn
|
||||
|
||||
@deffn Command self-insert-and-exit
|
||||
|
|
|
@ -2116,13 +2116,15 @@ variables.")
|
|||
(defun exit-minibuffer ()
|
||||
"Terminate this minibuffer argument."
|
||||
(interactive)
|
||||
(when (or
|
||||
(innermost-minibuffer-p)
|
||||
(not (minibufferp)))
|
||||
;; If the command that uses this has made modifications in the minibuffer,
|
||||
;; we don't want them to cause deactivation of the mark in the original
|
||||
;; buffer.
|
||||
;; A better solution would be to make deactivate-mark buffer-local
|
||||
;; (or to turn it into a list of buffers, ...), but in the mean time,
|
||||
;; this should do the trick in most cases.
|
||||
(when (innermost-minibuffer-p)
|
||||
(setq deactivate-mark nil)
|
||||
(throw 'exit nil))
|
||||
(error "%s" "Not in most nested minibuffer"))
|
||||
|
|
Loading…
Add table
Reference in a new issue