From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Let mode-line packages distinguish the selected-window Date: Sat, 26 Oct 2019 12:36:24 -0400 Message-ID: References: <87blu3pqyc.fsf@bernoul.li> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="103500"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Jonas Bernoulli Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Oct 26 18:36:45 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 1iOP3U-000QgR-PZ for ged-emacs-devel@m.gmane.org; Sat, 26 Oct 2019 18:36:44 +0200 Original-Received: from localhost ([::1]:40768 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iOP3O-0000Ih-FH for ged-emacs-devel@m.gmane.org; Sat, 26 Oct 2019 12:36:38 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60156) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iOP3F-00009P-VI for emacs-devel@gnu.org; Sat, 26 Oct 2019 12:36:30 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iOP3E-0005bO-6Q for emacs-devel@gnu.org; Sat, 26 Oct 2019 12:36:29 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:36973) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iOP3D-0005aw-Vo for emacs-devel@gnu.org; Sat, 26 Oct 2019 12:36:28 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id F2CF7449440; Sat, 26 Oct 2019 12:36:26 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id E3BF9449435; Sat, 26 Oct 2019 12:36:25 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1572107785; bh=rRm5zNT1QcQ1vTDIjif+y6p7Ag9V73p2Dt5DGUWH1jI=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=bD1Lcj+/YObzvM0einufKjRBShTjJyaHMlq4KmZLg8/13ukfgBzEWBhx+HqsvKqfj nBApiymMGYbmS4YXcwKgdy1h6FGXR1y8B9M8EbOwt3w5I5hSXfmmjBdm9Z+jJtnOBS zf7Pe2QsaKM2Z75bpIfQvAqCxRxlzk2Oq9bNzazwEnUYwDV274b4o3TJTK9QLVL15h ZNCKyO+3EZEaquTT1U32O4ytzfuvCAWMGOW1Qd21y/bjofD71f7Pkz/MlaPVnV9UyT Ko330xidmEYlwZ46JM0bhEMtlPoQjRKsAQ9EeoGenv2P54GlxS3fLhdNq97kW5fL/4 jFyjnv2hZlJzA== Original-Received: from pastel (unknown [216.154.30.71]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id A89121202A3; Sat, 26 Oct 2019 12:36:25 -0400 (EDT) In-Reply-To: <87blu3pqyc.fsf@bernoul.li> (Jonas Bernoulli's message of "Sat, 26 Oct 2019 15:38:19 +0200") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 132.204.25.50 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:241469 Archived-At: > 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: (add-function :before pre-redisplay-function (lambda (_) (setq remembered-selected-window (selected-window)))) or (add-hook 'pre-redisplay-functions (lambda (_) (setq remembered-selected-window (selected-window)))) > 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". > 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. Stefan