From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Window change functions Date: Sat, 05 Jan 2019 01:13:12 -0500 Message-ID: References: <5C21FB4B.7030005@gmx.at> <5C249D21.7070508@gmx.at> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1546668689 27826 195.159.176.226 (5 Jan 2019 06:11:29 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 5 Jan 2019 06:11:29 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: martin rudalics Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jan 05 07:11:25 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from listsout.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gffB6-00079d-TN for ged-emacs-devel@m.gmane.org; Sat, 05 Jan 2019 07:11:25 +0100 Original-Received: from localhost ([127.0.0.1]:48310 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gffDD-0007vd-5S for ged-emacs-devel@m.gmane.org; Sat, 05 Jan 2019 01:13:35 -0500 Original-Received: from eggsout.gnu.org ([209.51.188.92]:37003 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gffD6-0007vN-71 for emacs-devel@gnu.org; Sat, 05 Jan 2019 01:13:29 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gffD1-0004An-5z for emacs-devel@gnu.org; Sat, 05 Jan 2019 01:13:28 -0500 Original-Received: from chene.dit.umontreal.ca ([132.204.246.20]:57531) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gffD1-00049K-1j for emacs-devel@gnu.org; Sat, 05 Jan 2019 01:13:23 -0500 Original-Received: from fmsmemgm.homelinux.net (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id x056DDgU018537; Sat, 5 Jan 2019 01:13:14 -0500 Original-Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 993F7AE35F; Sat, 5 Jan 2019 01:13:12 -0500 (EST) In-Reply-To: <5C249D21.7070508@gmx.at> (martin rudalics's message of "Thu, 27 Dec 2018 10:36:33 +0100") X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 2 Rules triggered EDT_SA_DN_PASS=0, RV6454=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6454> : inlines <6991> : streams <1809171> : uri <2775035> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 132.204.246.20 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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:232183 Archived-At: > There are several reasons that favor delaying: > > (1) When finishing a window excursion by restoring the previous > configuration we should run 'window-configuration-change-hook' if > and only if something really changed. Telling whether something > really changed is hard and I doubt current Emacs does it right. I can't remember the last time I found save-window-excursion to be useful, so I don't find this use case important. > (2) 'balance-windows-area' is a good example for why we should delay > calling size change functions IMO: Its intermediate steps are not > really interesting for any client of that hook. This is indeed a valid case. While I do use balance-windows-area, I'm not sure how important this is, tho. > (3) Delaying hooks and running them all in one bunch allows to > reliably look at possibly related changes by consulting the > 'window-old-...' functions. I don't understand this. If we run the hook right away, the old state is easy to get to as well, isn't it? > (4) Some clients do the delaying themselves by putting an according > function on 'post-command-hook'. This won't be needed any more > with delayed execution. The flip side is that while it's currently easy to delay the execution using post-command-hook, it will be impossible to *un*delay the execution with the new setup. That's what worries me. > Note that 'window-size-change-functions' are currently already run > right in the middle of redisplay. Often, window sizes are correct > only *after* redisplay. Think of minibuffer window resizing or OK, miniwindow resizing is a valid case. >> Hmm... so to detect when a specific buffer stops being displayed you >> need to use the global part of the hook and you're not told which was >> the previously displayed buffer, so you need to keep track of >> that yourself. > > Correct. The right position to detect when a "specific buffer stops > being displayed" is (1) 'kill-buffer-hook' and *would be* (2) a > 'before-delete-window-hook' because right after its deletion a window > might get GCed immediately and (2) would not have anything else but > the buffer itself to work upon. So if someone sees a need for (2) > please tell me and I'll add such a hook (it won't cost much but some > lines in the manual). If we run window-buffer-change-functions eagerly (i.e. from set-window-buffer, as well as when creating/deleting a window), then it's easy to let the hook access the "old buffer" that's being replaced (we can even pass it as a parameter to the hook functions). >> IIUC this hook is hence also run for changes to frame-selected-window, >> even when that frame is not selected? I wonder if it's a good idea. >> frame-selected-window is a fairly obscure detail, in my experience. > If someone changes it separately (that is, sets it for a non-selected > frame), there is now a hook to trace that. Right, and my question is: why bother? I think it makes the API more complex with zero benefit. > He could try it though. Didn't notice anything funny. Stefan