From: Michael Heerdegen <michael_heerdegen@web.de>
To: help-gnu-emacs@gnu.org
Subject: Re: Propertize mode-line contents only for mode-line of selected window?
Date: Sun, 01 Mar 2015 03:40:36 +0100 [thread overview]
Message-ID: <87385pmod7.fsf@web.de> (raw)
In-Reply-To: 87385q8g5v.fsf@gmail.com
Alexis <flexibeast@gmail.com> writes:
> i'd like to modify the value of `mode-line-format` such that one
> specific part of it is propertized in a specific way only for the
> mode-line of the currently selected window. Is there some way of
> achieving this via ELisp? i've not been able to make any progress on
> this with various permutations of `frame-selected-window`,
> `window-buffer`, `current-buffer` etc. ....
Yes, this will all not work. The reason is that when any mode-line in
any window is refreshed, its window is internally temporarily selected.
So you will need to remember the selected window in a variable, or
something like that - here is an example:
--8<---------------cut here---------------start------------->8---
(defvar my-selected-win nil)
(defun my-set-selected-win ()
(setq my-selected-win (selected-window)))
(add-hook 'post-command-hook
#'my-set-selected-win)
(defun my-ml-emphasize-selected-window ()
(and (eq (selected-window) my-selected-win) "!!!"))
;;; example
(push '(:eval (my-ml-emphasize-selected-window))
(default-value 'mode-line-format))
--8<---------------cut here---------------end--------------->8---
Using `post-command-hook' seems a bit exaggerated, but
`window-configuration-change-hook' is not triggered for `other-window'
and the like, and advising `select-window' is also not an option because
of its internal use to calculate mode-lines of all windows. Maybe it
can be done better, dunno.
Michael.
next prev parent reply other threads:[~2015-03-01 2:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-28 10:49 Propertize mode-line contents only for mode-line of selected window? Alexis
2015-03-01 2:40 ` Michael Heerdegen [this message]
2015-03-01 3:23 ` Alexis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87385pmod7.fsf@web.de \
--to=michael_heerdegen@web.de \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).