From: Eshel Yaron Date: Tue, 24 Dec 2024 17:13:01 +0000 (+0100) Subject: New hook 'read-shell-command-minibuffer-setup-hook' X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9a8de1acb427fd9dc5a662ed6a45739b8cb65bbd;p=emacs.git New hook 'read-shell-command-minibuffer-setup-hook' --- diff --git a/lisp/simple.el b/lisp/simple.el index 142049ab25f..91d9b3ac07d 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -4194,6 +4194,9 @@ after the default value." map) "Keymap used for completing shell commands in minibuffer.") +(defvar read-shell-command-minibuffer-setup-hook nil + "Hook run by `read-shell-command' when entering the minibuffer.") + (defun read-shell-command (prompt &optional initial-contents hist &rest args) "Read a shell command from the minibuffer. The arguments are the same as the ones of `read-from-minibuffer', @@ -4204,7 +4207,10 @@ to `shell-command-history'." (lambda () (shell-completion-vars) (setq-local minibuffer-default-add-function - #'minibuffer-default-add-shell-commands)) + #'minibuffer-default-add-shell-commands) + (add-hook 'minibuffer-exit-hook + #'minibuffer-kill-completions-buffer nil t) + (run-hooks 'read-shell-command-minibuffer-setup-hook)) (apply #'read-from-minibuffer prompt initial-contents minibuffer-local-shell-command-map nil