GNU bug report logs - #29050
26.0; Change in when `window-configuration-change-hook' is run

Previous Next

Package: emacs;

Reported by: Drew Adams <drew.adams <at> oracle.com>

Date: Sun, 29 Oct 2017 01:27:01 UTC

Severity: minor

Found in version 26.0

Done: martin rudalics <rudalics <at> gmx.at>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 29050 in the body.
You can then email your comments to 29050 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#29050; Package emacs. (Sun, 29 Oct 2017 01:27:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Drew Adams <drew.adams <at> oracle.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 29 Oct 2017 01:27:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 26.0; Change in when `window-configuration-change-hook' is run
Date: Sat, 28 Oct 2017 18:25:35 -0700 (PDT)
This change does not seem right (from NEWS):

 *** Resizing a frame no longer runs 'window-configuration-change-hook'.
 'window-size-change-functions' should be used instead.

Previously you could have a hook on 'window-configuration-change-hook'
that would take effect for frame resizings.  Now you cannot.

Perhaps someone thought that just telling users to use
'window-size-change-functions' instead would suffice.  No.  That hook
(which already existed, and which was fine as it was) is for ABNORMAL
hooks.  This incompatible change means that you cannot use the same,
NORMAL hook for both'window-configuration-change-hook' and
'window-size-change-functions'.

So if you want the behavior you had before, i.e., you want a function to
be invoked for both kinds of changes, you are out of luck.  You need to
have two different functions, or you need to at least change the
function to accept a frame argument, even if it is not used.  Why?

Example:

(define-minor-mode pretty-control-l-mode
    "Toggle pretty display of Control-l (`^L') characters.
With ARG, turn pretty display of `^L' on if and only if ARG is positive."
  :init-value nil :global t :group 'Pretty-Control-L
  (if pretty-control-l-mode
      (add-hook 'window-configuration-change-hook 'refresh-pretty-control-l)
    (remove-hook 'window-configuration-change-hook 'refresh-pretty-control-l))
  (walk-windows
   (lambda (window)
     (let ((display-table  (or (window-display-table window)
                               (make-display-table))))
       (aset display-table ?\014 (and pretty-control-l-mode
                                      (pp^L-^L-display-table-entry window)))
       (set-window-display-table window display-table)))
   'no-minibuf
   'visible))

The hook function no longer kicks in for "frame resizing", which also
means that it no longer kicks in when a frame is created.  So now the
code needs to add the hook function to both hooks (a normal hook and an
abnormal hook).  And the hook function, `refresh-pretty-control-l', now
needs to be changed to accept a phantom FRAME arg:

(defun refresh-pretty-control-l (&optional _)
  "Reinitialize `pretty-control-l-mode', if on, to update the display."
  (interactive)
  (when pretty-control-l-mode (pretty-control-l-mode t)))

Why this incompatible change?

In GNU Emacs 26.0.90 (build 3, x86_64-w64-mingw32)
 of 2017-10-13
Repository revision: 906224eba147bdfc0514090064e8e8f53160f1d4
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --without-dbus --host=x86_64-w64-mingw32
 --without-compress-install 'CFLAGS=-O2 -static -g3''




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29050; Package emacs. (Sun, 29 Oct 2017 11:20:03 GMT) Full text and rfc822 format available.

Message #8 received at 29050 <at> debbugs.gnu.org (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: Drew Adams <drew.adams <at> oracle.com>, 29050 <at> debbugs.gnu.org
Subject: Re: bug#29050: 26.0; Change in when `window-configuration-change-hook'
 is run
Date: Sun, 29 Oct 2017 12:19:03 +0100
>   *** Resizing a frame no longer runs 'window-configuration-change-hook'.
>   'window-size-change-functions' should be used instead.
>
> Previously you could have a hook on 'window-configuration-change-hook'
> that would take effect for frame resizings.  Now you cannot.
>
> Perhaps someone thought that just telling users to use
> 'window-size-change-functions' instead would suffice.  No.  That hook
> (which already existed, and which was fine as it was) is for ABNORMAL
> hooks.  This incompatible change means that you cannot use the same,
> NORMAL hook for both'window-configuration-change-hook' and
> 'window-size-change-functions'.
>
> So if you want the behavior you had before, i.e., you want a function to
> be invoked for both kinds of changes, you are out of luck.  You need to
> have two different functions, or you need to at least change the
> function to accept a frame argument, even if it is not used.  Why?

In earlier Emacsen, changing the frame size was allowed to delete all
windows but the selected one.  Nowadays, changing the frame size does
not delete windows any more and so does no more change the window
configuration proper but only the sizes of individual windows.

'window-configuration-change-hook' is a quite expensive hook which is
run for way too many functions in the windows area.  It's expensive
because it's run for every single invocation of these functions and
often even if nothing had changed at all.  I plan to run it exclusively
for the following cases - window deletion and creation and displaying a
different buffer in a window - which are all real changes.  Any window
resizing is covered by ‘window-size-change-functions’ which is now run
(almost) only when the size of a window really changed.

martin





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29050; Package emacs. (Mon, 30 Oct 2017 00:12:02 GMT) Full text and rfc822 format available.

Message #11 received at 29050 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: martin rudalics <rudalics <at> gmx.at>, 29050 <at> debbugs.gnu.org
Subject: RE: bug#29050: 26.0; Change in when
 `window-configuration-change-hook' is run
Date: Sun, 29 Oct 2017 17:10:55 -0700 (PDT)
> In earlier Emacsen, changing the frame size was allowed to delete all
> windows but the selected one.  Nowadays, changing the frame size does
> not delete windows any more and so does no more change the window
> configuration proper but only the sizes of individual windows.
> 
> 'window-configuration-change-hook' is a quite expensive hook which is
> run for way too many functions in the windows area.  It's expensive
> because it's run for every single invocation of these functions and
> often even if nothing had changed at all.  I plan to run it exclusively
> for the following cases - window deletion and creation and displaying a
> different buffer in a window - which are all real changes.  Any window
> resizing is covered by ‘window-size-change-functions’ which is now run
> (almost) only when the size of a window really changed.

OK.




Reply sent to martin rudalics <rudalics <at> gmx.at>:
You have taken responsibility. (Mon, 30 Oct 2017 08:26:02 GMT) Full text and rfc822 format available.

Notification sent to Drew Adams <drew.adams <at> oracle.com>:
bug acknowledged by developer. (Mon, 30 Oct 2017 08:26:02 GMT) Full text and rfc822 format available.

Message #16 received at 29050-done <at> debbugs.gnu.org (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: Drew Adams <drew.adams <at> oracle.com>, 29050-done <at> debbugs.gnu.org
Subject: Re: bug#29050: 26.0; Change in when `window-configuration-change-hook'
 is run
Date: Mon, 30 Oct 2017 09:24:50 +0100
>> 'window-configuration-change-hook' is a quite expensive hook which is
>> run for way too many functions in the windows area.  It's expensive
>> because it's run for every single invocation of these functions and
>> often even if nothing had changed at all.  I plan to run it exclusively
>> for the following cases - window deletion and creation and displaying a
>> different buffer in a window - which are all real changes.  Any window
>> resizing is covered by ‘window-size-change-functions’ which is now run
>> (almost) only when the size of a window really changed.
>
> OK.

Closing this bug then.

Thanks, martin





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 27 Nov 2017 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 7 years and 263 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.