Cancel minibuffer when clicking another window

Joost Kremers <[email protected]>
Newsgroups gmane.emacs.help
Message-ID <[email protected]>
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?

I've been trying with `mouse-leave-buffer-hook` and by adding advice before
`mouse-set-point`, with various functions (`keyboard-quit`,
`minibuffer-keyboard-quit`, `abort-minibuffers`, `abort-recursive-edit`),
but either nothing happens, or I get an error "not in a minibuffer"...

TIA

-- 
Joost Kremers
Life has its moments
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.