* Detect content in minibuffer
@ 2014-01-30 14:06 Miguel Guedes
2014-01-30 14:36 ` Nicolas Richard
2014-01-30 15:13 ` Stefan Monnier
0 siblings, 2 replies; 3+ messages in thread
From: Miguel Guedes @ 2014-01-30 14:06 UTC (permalink / raw)
To: help-gnu-emacs
I'm using the following to query the size of the buffer associated with
the minibuffer but it always returns 0 even when there is a message
currently being displayed in the echo area (say, documentation by eldoc
or anything else). The aim is to not echo anything when there's
currently content in the echo area.
I've tried:
(with-current-buffer (window-buffer (minibuffer-window))
(unless (> 0 (buffer-size))
.
:
.
and [0],
(with-current-buffer (get-buffer " *Echo Area 0*")
(unless (> 0 (buffer-size))
.
:
.
What's wrong with my approach?
--
[0] Found excerpt referring to the echo area as "*Echo Area 0*" at
http://www.emacswiki.org/emacs/EchoArea
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Detect content in minibuffer
2014-01-30 14:06 Detect content in minibuffer Miguel Guedes
@ 2014-01-30 14:36 ` Nicolas Richard
2014-01-30 15:13 ` Stefan Monnier
1 sibling, 0 replies; 3+ messages in thread
From: Nicolas Richard @ 2014-01-30 14:36 UTC (permalink / raw)
To: Miguel Guedes; +Cc: help-gnu-emacs
Miguel Guedes <miguel.a.guedes@gmail.com> writes:
> I'm using the following to query the size of the buffer associated
> with the minibuffer but it always returns 0 even when there is a
> message currently being displayed in the echo area (say, documentation
> by eldoc or anything else). The aim is to not echo anything when
> there's currently content in the echo area.
I guess there are two problems :
1. minibuffer is not the same as echo area. Try
M-: M-: (with-current-buffer (window-buffer (minibuffer-window)) (buffer-string))
(i.e. enter a recursive minibuffer) and then you get something.
2. the command loop erases the echo area before running commands, so
whenever you try running your code interactively, it'll report an empty
echo area. Try this instead:
(progn
(message "foo!")
(with-current-buffer " *Echo Area 0*"
(format "Found string: %s" (buffer-string))))
Also, the functions current-message and with-temp-message might be of
interest to you. (But note that current-message also suffers the
problems of being cleared if you call it interactively !)
HTH,
--
Nico.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Detect content in minibuffer
2014-01-30 14:06 Detect content in minibuffer Miguel Guedes
2014-01-30 14:36 ` Nicolas Richard
@ 2014-01-30 15:13 ` Stefan Monnier
1 sibling, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2014-01-30 15:13 UTC (permalink / raw)
To: help-gnu-emacs
> I'm using the following to query the size of the buffer associated with the
> minibuffer but it always returns 0 even when there is a message currently
> being displayed in the echo area (say, documentation by eldoc or anything
> else). The aim is to not echo anything when there's currently content in
> the echo area.
You might like to try (current-message).
> (with-current-buffer (window-buffer (minibuffer-window))
> (unless (> 0 (buffer-size))
For some reason, (window-buffer (minibuffer-window)) returns the " *Minibuf-0*"
buffer rather than the " *Echo Area 0*" buffer.
> (with-current-buffer (get-buffer " *Echo Area 0*")
> (unless (> 0 (buffer-size))
This should work. At least in my tests:
M-: (progn (message "foob") (with-current-buffer " *Echo Area 0*"
(message "%S" (buffer-size)))) RET
returns 4.
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-01-30 15:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-30 14:06 Detect content in minibuffer Miguel Guedes
2014-01-30 14:36 ` Nicolas Richard
2014-01-30 15:13 ` Stefan Monnier
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.