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 16:36:19 -0400 Message-ID: References: <87blu3pqyc.fsf@bernoul.li> <877e4r5mu6.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="265089"; 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 22:49:18 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 1iOSzr-0016kw-GR for ged-emacs-devel@m.gmane.org; Sat, 26 Oct 2019 22:49:15 +0200 Original-Received: from localhost ([::1]:42158 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iOSzq-0006YW-Bl for ged-emacs-devel@m.gmane.org; Sat, 26 Oct 2019 16:49:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55613) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iOSnT-0004BV-EB for emacs-devel@gnu.org; Sat, 26 Oct 2019 16:36:28 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iOSnR-0003IE-JG for emacs-devel@gnu.org; Sat, 26 Oct 2019 16:36:26 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:23283) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iOSnR-0003Hr-D6 for emacs-devel@gnu.org; Sat, 26 Oct 2019 16:36:25 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 496581004C7; Sat, 26 Oct 2019 16:36:24 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id BDE9D1002E2; Sat, 26 Oct 2019 16:36:22 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1572122182; bh=WqiqB+/8VCcBJCg8f8+gEccteyCfVXEa9LJf+M1Ii1Y=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=RaTCWl/A/B81VWESMOrGQulXIGYfekDx8i7EJyCU4J0BRnSI5yVx7H6FEw8shbUu8 vf16isXPjhIC+ASC5ZSwB5iEwhbUYI8ikFnMj40bYjjWlleFsHknrXvc/QCbN+URy9 8izGmuaZX7qXAagxT2zuey6wRsItcH6ZWV3wrbENQhZcB4nxFwAP5Lj7vEqnp26UC8 f5efKqCCnLakeyWhsTWXUB5PNEeq+2iF0HgmGM8Q3NRTXEfG3jcyjXNK3BVi9sbYgd m/YNQUL8Klo/HM/Dtqwtf0kZatmOFM54lbQW4ZT/JEXfM9zJTU8lHiFu+HQKAnHWPY 758Dewo5M5niQ== Original-Received: from pastel (unknown [216.154.30.71]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 786F712039E; Sat, 26 Oct 2019 16:36:22 -0400 (EDT) In-Reply-To: <877e4r5mu6.fsf@bernoul.li> (Jonas Bernoulli's message of "Sat, 26 Oct 2019 21:27:29 +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:241481 Archived-At: > 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) I don't understand what this is about. From this all I can see is that moody--active-window will always be nil, so it's clearly not quite right ;-) This matters if we want to provide the info from the C code: we'd better make sure we provide the right info then, but if different packages need slightly different info we're in trouble. This said, AFAICT, minibuffer-window-active-p can be used later on so I get the impression that the hook I suggested would provide enough info that you can easily derive moody's specific flavor of that info. > 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". Maybe you're right, tho I'm not sure really which of the two options would be better in an ideal world. > But that would be a breaking change, so maybe not. Indeed, I think this ship has sailed so we don't need to figure out which option is best. Stefan