[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Let mode-line packages distinguish the selected-window
From: |
Jonas Bernoulli |
Subject: |
Re: Let mode-line packages distinguish the selected-window |
Date: |
Sat, 26 Oct 2019 21:27:29 +0200 |
User-agent: |
mu4e 1.1.0; emacs 27.0.50 |
Stefan Monnier <address@hidden> writes:
>> To deal with this the packages mentioned above resort to using several
>> hook functions and advice to keep track of "the" selected window and
>> then they do something like:
>
> AFAIK since Emacs-24.4 only one hook is needed:
Well it seems I (or any of the maintainers of the other packages,
really) should have asked a bit earlier. oO
>> Because keeping remembered-selected-window up-to-date involves several
>> hooks and advises this is rather ugly and fragile.
>
> With `pre-redisplay-function(s)` is should be "easy and reliable".
That's very promising indeed. The minibuffer window needs to be handled
a bit differently, I think:
(defun moody--set-active-window (_)
(let ((win (selected-window)))
(unless (minibuffer-window-active-p win)
(setq moody--active-window win))))
(add-hook 'pre-redisplay-functions #'moody--set-active-window)
>> In summary, please add a way for functions that format elements of the
>> mode-line to determine whether these elements are going to be used in
>> the selected or some other window.
>
> Despite what the above may suggest, I fully agree: while it's now easy
> to "roll your own", this is a common need and we should provide this
> info directly.
That would be nice. (And no Eli, I don't have a patch ready. Not much
of a C guy. Not at all really.)
But even though I suggested something like that, I feel the
remembered-selected-window approach is a bit hackish. IMO it would be
nicer if instead of that variable regular selected-window would return
"that window" while a new function/variable named something like
mode-line-window returned the "window whose mode-line is currently being
updated". But that would be a breaking change, so maybe not.
Jonas
- Re: Let mode-line packages distinguish the selected-window, (continued)
- Re: Let mode-line packages distinguish the selected-window, Jonas Bernoulli, 2019/10/28
- Re: Let mode-line packages distinguish the selected-window, martin rudalics, 2019/10/29
- Re: Let mode-line packages distinguish the selected-window, Eli Zaretskii, 2019/10/29
- Re: Let mode-line packages distinguish the selected-window, martin rudalics, 2019/10/29
- Re: Let mode-line packages distinguish the selected-window, Eli Zaretskii, 2019/10/29
- Re: Let mode-line packages distinguish the selected-window, martin rudalics, 2019/10/30
- Re: Let mode-line packages distinguish the selected-window, Eli Zaretskii, 2019/10/30
- Re: Let mode-line packages distinguish the selected-window, Eli Zaretskii, 2019/10/28
- Re: Let mode-line packages distinguish the selected-window, Jonas Bernoulli, 2019/10/29
Re: Let mode-line packages distinguish the selected-window, Stefan Monnier, 2019/10/26
- Re: Let mode-line packages distinguish the selected-window,
Jonas Bernoulli <=