unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Jonas Bernoulli <jonas@bernoul.li>
To: martin rudalics <rudalics@gmx.at>
Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org
Subject: Re: Let mode-line packages distinguish the selected-window
Date: Sun, 27 Oct 2019 22:13:50 +0100	[thread overview]
Message-ID: <87tv7triwh.fsf@bernoul.li> (raw)
In-Reply-To: <9a34b0c1-149b-a850-db88-b9d7cb5c751e@gmx.at>


martin rudalics <rudalics@gmx.at> writes:

>> I understand the general idea, but in the display code the devil is in
>> the details, and this particular place is tricky already.  One issue
>> that bothers me is what happens when we are in the minibuffer window.
>
> FWIW with Emacs 27 the form
>
> (or (eq (selected-window) (old-selected-window))
>     (and (not (zerop (minibuffer-depth)))
> 	 (eq (selected-window)
> 	     (with-selected-window (minibuffer-window)
> 	       (minibuffer-selected-window)))))
>
> should handle all concerns.

This works well.  I have already updated moody to use this approach when
possible.

But it won't give the desired behavior in some weird edge-case.  Another
package of mine did something weird which did trigger such an edge-case.
I already fixed that, but yet another package might do something similar
and actually have a legimite reason to do so.

More on that later, but first lets remember what we ultimately want.
Not that the above isn't useful in its own right but what the packages
that I mentioned really want to know is:

  Which face (mode-line or mode-line-inactive) is the mode-line of this
  window using?

That is of course closely related to the question:

  Is the is the "selected" window?

But the answer to the first question can not always be derived from the
answer to the second.

And here is a weird edge case where doing so is not possible:

  (add-hook 'pre-command-hook (lambda () (force-mode-line-update t)))

Sure that is weird, but that's not the point.  With this hook function
we can observe the following behavior:

1. Enter minibuffer.
2. Switch to another frame.  (Without leaving minibuffer first.)
3. Observe that the window which was the selected window before
   (1) now uses mode-line-inactive but your code snippet returns t.

I think the only 100% sure way to be able to answer the first question
is to record that decision at the time when it is made.  Emphasize on
both "that decision" (not some closely related one) and "at that time",
i.e. when CURRENT_MODE_LINE_FACE_ID_3 is being called by
display_mode_lines, then that value has to be saved in a way that is
accessible from lisp.

Now I am not saying this absolutely has to be done.  I am quite happy
with the above code.  But since I noticed this edge-case I though I
would point it out in case you decide that this is something we cannot
live with.

Cheers,
Jonas



  parent reply	other threads:[~2019-10-27 21:13 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-26 13:38 Let mode-line packages distinguish the selected-window Jonas Bernoulli
2019-10-26 14:01 ` Eli Zaretskii
2019-10-26 21:10   ` martin rudalics
2019-10-27  5:01     ` Eli Zaretskii
2019-10-27  7:48       ` martin rudalics
2019-10-27 21:13     ` Jonas Bernoulli [this message]
2019-10-28  9:40       ` martin rudalics
2019-10-28 10:32         ` Jonas Bernoulli
2019-10-29  9:27           ` martin rudalics
2019-10-29 12:24             ` Eli Zaretskii
2019-10-29 18:05               ` martin rudalics
2019-10-29 18:46                 ` Eli Zaretskii
2019-10-30  8:14                   ` martin rudalics
2019-10-30 16:10                     ` Eli Zaretskii
2019-10-28 15:55       ` Eli Zaretskii
2019-10-29 11:50         ` Jonas Bernoulli
2019-10-26 16:36 ` Stefan Monnier
2019-10-26 19:27   ` Jonas Bernoulli
2019-10-26 19:41     ` Eli Zaretskii
2019-10-26 20:36     ` Stefan Monnier
2019-10-27 18:08       ` Jonas Bernoulli
2019-10-27 21:55         ` Stefan Monnier

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=87tv7triwh.fsf@bernoul.li \
    --to=jonas@bernoul.li \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=rudalics@gmx.at \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).