* Re: Recognizing active/inactive mode-line in (:eval ...) form in mode-line-string
[not found] <mailman.21116.1362070608.855.help-gnu-emacs@gnu.org>
@ 2013-03-01 19:21 ` Michael Heerdegen
0 siblings, 0 replies; 2+ messages in thread
From: Michael Heerdegen @ 2013-03-01 19:21 UTC (permalink / raw)
To: help-gnu-emacs
Alessandro Piras <laynor@gmail.com> writes:
> Is there a way to know if the mode-line is active in a (:eval ...)
> form inside the mode-line-string?
>
> A simple example:
> mode-line-string =>
> ("%e" (:eval (if <condition> "foo" "bar")))
>
> I would like to see "foo" on the mode-line of the active window,
> "bar" on the others.
This is a very good question!
AFAICT, when the mode-line of any window is calculated, it is
temporarily selected. This would mean that such a condition doesn't
exist. So, you'll need some trick, e.g. something like
--8<---------------cut here---------------start------------->8---
(add-hook 'post-command-hook
(lambda () (setq my-selected-window (selected-window))))
(push '(:eval (if (eq (selected-window) my-selected-window)
"foo" "bar")) default-mode-line-format)
--8<---------------cut here---------------end--------------->8---
i.e., try to remember and update the selected window in a global
variable. Probably this can be achieved more elegantly than above.
Note that you still may have to force a mode-line update to always have
the right "foo" or "bar".
Regards,
Michael.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Recognizing active/inactive mode-line in (:eval ...) form in mode-line-string
@ 2013-02-28 11:25 Alessandro Piras
0 siblings, 0 replies; 2+ messages in thread
From: Alessandro Piras @ 2013-02-28 11:25 UTC (permalink / raw)
To: help-gnu-emacs
Is there a way to know if the mode-line is active in a (:eval ...)
form inside the mode-line-string?
A simple example:
mode-line-string =>
("%e" (:eval (if <condition> "foo" "bar")))
I would like to see "foo" on the mode-line of the active window,
"bar" on the others.
--
AP
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-03-01 19:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.21116.1362070608.855.help-gnu-emacs@gnu.org>
2013-03-01 19:21 ` Recognizing active/inactive mode-line in (:eval ...) form in mode-line-string Michael Heerdegen
2013-02-28 11:25 Alessandro Piras
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.