>> >> (if (and >> >> ;; When `inhibit-message' is non-nil, the intention was to just >> >> ;; log the message to the *Messages* buffer using `message'. >> >> (null inhibit-message) >> >> (window-live-p (active-minibuffer-window)) >> >> (window-live-p (old-selected-window)) >> >> (bufferp (window-buffer (old-selected-window))) >> >> (minibufferp (window-buffer (old-selected-window)))) >> > >> > Btw, can you explain why every part of this condition is needed? IOW, >> > why isn't just the below enough? >> > >> > (window-live-p (active-minibuffer-window)) >> > >> > (I do understand the reason for the test of inhibit-message). >> > >> > Maybe the other conditions need a comment to explain them? >> >> Unfortunately, I forgot why they were added, i.e. during testing >> I added them one by one when noticed that some cases don't work. >> Now I'll try to reproduce these cases by removing conditions >> and checking which part doesn't work. Now I recall why just (window-live-p (active-minibuffer-window)) is not enough. Because it returns non-nil even when the current buffer is not the minibuffer, but the minibuffer was activated earlier. Test case: 0. emacs -Q 1. M-x ;; activate the minibuffer 2. C-x o ;; switch back to *scratch* 3. Eval in *scratch* buffer: (window-live-p (active-minibuffer-window)) => t A message overlay should not be added to the *scratch* buffer, so it's important to check if old-selected-window is a minibuffer window (i.e. the current buffer is the minibuffer). >> But if implementation would be straightforward and if you see no problems >> then why not. > > The implementation looks straightforward to me, since you already > implemented almost all of it in that ELPA package. What's left is > minor details. Let's iron out the details. A new patch attached works well in all cases I tested (dabbrev, icomplete, etc.) But I'm sure it could be improved further because I might have made wrong assumptions on the C side, or something.