Re: Cancel minibuffer when clicking another window
Stephen Berman <[email protected]>
| Newsgroups | gmane.emacs.help |
|---|---|
| Message-ID | <[email protected]> |
On Wed, 04 Mar 2026 12:47:15 +0100 Joost Kremers <[email protected]> wrote: > Hi list, > > When Emacs reads input in the minibuffer (i.e., with `read-from-minibuffer` > or `completing-read`, etc.) and you click some other window with the mouse, > that window is selected, but the minibuffer input isn't cancelled. > > Is there a way to automatically cancel the minibuffer input when clicking > another window? Maybe this does what you want: (defun my-exit-minibuffer () (let ((miniwin (active-minibuffer-window))) (when (and miniwin (not (eq miniwin (selected-window))) (mouse-event-p last-command-event) (exit-minibuffer))))) (add-hook 'post-command-hook #'my-exit-minibuffer) Steve Berman