I tried to advice read-from-minibuffer and read-string but nothing worked.

For example, when I called yes-or-no-p, no advice handlers were called.

Is there general way how to detect that user is interacting with minibuffer? I need it because I have some package which in idle time print some data into minibuffer, problem is, when I interact somehow with minibuffer and wait here for a while, that package will simply print some garbage into it when I need it for something completely different.

EDIT: Currently I use following solution, but its kinda bad, I want something generic.

(advice-add #'yes-or-no-p
            (lambda (oldfun &rest args)
              ;; eat all messages
              (setq eldoc-message-function
                    (lambda (&rest args) nil))
                  (apply oldfun args)
                (setq eldoc-message-function
  • Just what do you mean by a "minibuffer interaction"? @phils answered in terms of activation and deactivation (entering and exiting) of the minibuffer. Is that what you mean? Or do you mean some action on the user's part while the minibuffer is active? Please try to clarify the question a bit.
    – Drew
    Sep 4, 2018 at 22:45
  • For example, calling yes-or-no-p. Even hooks from phils doesnt work, only way which I see is to use awful lot of advices.
    – dev1223
    Sep 7, 2018 at 18:02
  • You should give further consideration to @phils ' solution below, but if you do continue with the advice above, then you need to change those setqs to fsets. Apr 17, 2022 at 10:23

1 Answer 1


There are hooks for that, so you shouldn't need to resort to advice.

  • minibuffer-setup-hook
  • minibuffer-exit-hook

However you could possibly just use the minibuffer-line package from GNU ELPA?

This package lets you display various status information in the minibuffer window instead of the mode-line. Of course, this is only displayed when the minibuffer window is not already used for other things (e.g. a minibuffer or an each area message).

That package doesn't actually use the hooks either, but rather a trick of using *Minibuf-0* (which under normal circumstances is always empty, and which by my reading the redisplay loop uses to display 'nothing' in that window when nothing else should be displayed).

  • Not works for yes-or-no-p.
    – dev1223
    Sep 7, 2018 at 18:03
  • The hooks? or minibuffer-line? (or both?)
    – phils
    Sep 8, 2018 at 1:26
  • Minibuffer line looks like it should work, but I dont tried it in current phase because I consider it somewhat "hacky". Advices are not optimal solution, but very explicit, so I will probably not forget how it works in future. I will try minibuffer line and write how it goes.
    – dev1223
    Sep 9, 2018 at 9:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.