From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Jonas Bernoulli Newsgroups: gmane.emacs.devel Subject: Re: Let mode-line packages distinguish the selected-window Date: Sun, 27 Oct 2019 22:13:50 +0100 Message-ID: <87tv7triwh.fsf@bernoul.li> References: <87blu3pqyc.fsf@bernoul.li> <83wocrtxl3.fsf@gnu.org> <9a34b0c1-149b-a850-db88-b9d7cb5c751e@gmx.at> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="254806"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: mu4e 1.1.0; emacs 27.0.50 Cc: Eli Zaretskii , emacs-devel@gnu.org To: martin rudalics Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Oct 27 22:14:35 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iOpru-001462-1W for ged-emacs-devel@m.gmane.org; Sun, 27 Oct 2019 22:14:34 +0100 Original-Received: from localhost ([::1]:49552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iOprs-0007uv-Jy for ged-emacs-devel@m.gmane.org; Sun, 27 Oct 2019 17:14:32 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56873) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iOprP-0007tz-9c for emacs-devel@gnu.org; Sun, 27 Oct 2019 17:14:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iOprO-0000AC-0G for emacs-devel@gnu.org; Sun, 27 Oct 2019 17:14:03 -0400 Original-Received: from mail.hostpark.net ([212.243.197.30]:33080) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iOprM-0008VO-7y; Sun, 27 Oct 2019 17:14:00 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by mail.hostpark.net (Postfix) with ESMTP id 5D3631669C; Sun, 27 Oct 2019 22:13:56 +0100 (CET) X-Virus-Scanned: by Hostpark/NetZone Mailprotection at hostpark.net Original-Received: from mail.hostpark.net ([127.0.0.1]) by localhost (mail0.hostpark.net [127.0.0.1]) (amavisd-new, port 10124) with ESMTP id m9ngCvLMiFyR; Sun, 27 Oct 2019 22:13:54 +0100 (CET) Original-Received: from p2 (212-51-149-230.fiber7.init7.net [212.51.149.230]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.hostpark.net (Postfix) with ESMTPSA id C38A3165DD; Sun, 27 Oct 2019 22:13:54 +0100 (CET) In-reply-to: <9a34b0c1-149b-a850-db88-b9d7cb5c751e@gmx.at> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.243.197.30 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:241526 Archived-At: martin rudalics 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