GNU bug report logs - #38143
27.0.50; Say that before-make-frame-hook & after-make-frame-functions are not invoked for the initial frame

Previous Next

Package: emacs;

Reported by: Óscar Fuentes <ofv <at> wanadoo.es>

Date: Sat, 9 Nov 2019 03:19:01 UTC

Severity: normal

Found in version 27.0.50

Fixed in version 29.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

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 38143 in the body.
You can then email your comments to 38143 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#38143; Package emacs. (Sat, 09 Nov 2019 03:19:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Óscar Fuentes <ofv <at> wanadoo.es>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 09 Nov 2019 03:19:01 GMT) Full text and rfc822 format available.

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

From: Óscar Fuentes <ofv <at> wanadoo.es>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.0.50; Say that before-make-frame-hook &
 after-make-frame-functions are not invoked for the initial frame
Date: Sat, 09 Nov 2019 04:18:41 +0100
Currently de docstrings of those variables do not mention that they are
not invoked for the initial frame. Adding that detail is trivial, except
that when the initial frame belongs to a daemon they are invoked.

I'm not sure how to word that information.


In GNU Emacs 27.0.50 (build 3, x86_64-pc-linux-gnu, X toolkit)
 of 2019-11-09 built on sky
Repository revision: f8284f1e408b38e6a3c0e2a1d5a465fefac6800a
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12004000
System Description: Debian GNU/Linux bullseye/sid




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38143; Package emacs. (Sat, 09 Nov 2019 09:02:02 GMT) Full text and rfc822 format available.

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

From: martin rudalics <rudalics <at> gmx.at>
To: Óscar Fuentes <ofv <at> wanadoo.es>, 38143 <at> debbugs.gnu.org
Subject: Re: bug#38143: 27.0.50; Say that before-make-frame-hook &
 after-make-frame-functions are not invoked for the initial frame
Date: Sat, 9 Nov 2019 10:01:34 +0100
> Currently de docstrings of those variables do not mention that they are
> not invoked for the initial frame. Adding that detail is trivial, except
> that when the initial frame belongs to a daemon they are invoked.
>
> I'm not sure how to word that information.

The reason is that the initial frame is not made by 'make-frame'.  The
Elisp manual says

     Note that any functions added to these hooks by your initial file are
  usually not run for the initial frame, since Emacs reads the initial
  file only after creating that frame.  However, if the initial frame is
  specified to use a separate minibuffer frame (*note Minibuffers and
  Frames::), the functions will be run for both, the minibuffer-less and
  the minibuffer frame.

This explanation is slightly misleading: Since the initial frame is
not created by 'make-frame', Emacs would not run these hooks even if
it did read the initial file earlier.  Hints for improving the
documentation are welcome.

martin




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38143; Package emacs. (Sat, 09 Nov 2019 09:28:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: martin rudalics <rudalics <at> gmx.at>
Cc: ofv <at> wanadoo.es, 38143 <at> debbugs.gnu.org
Subject: Re: bug#38143: 27.0.50;
 Say that before-make-frame-hook & after-make-frame-functions are not
 invoked for the initial frame
Date: Sat, 09 Nov 2019 11:27:29 +0200
> From: martin rudalics <rudalics <at> gmx.at>
> Date: Sat, 9 Nov 2019 10:01:34 +0100
> 
>       Note that any functions added to these hooks by your initial file are
>    usually not run for the initial frame, since Emacs reads the initial
>    file only after creating that frame.  However, if the initial frame is
>    specified to use a separate minibuffer frame (*note Minibuffers and
>    Frames::), the functions will be run for both, the minibuffer-less and
>    the minibuffer frame.
> 
> This explanation is slightly misleading: Since the initial frame is
> not created by 'make-frame', Emacs would not run these hooks even if
> it did read the initial file earlier.

But without an init file, where would the hooks come from?

And anyway, the issue is probably only meaningful for users who define
these hooks in init files.  So I think the only missing piece in the
above is to mention the daemon case.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38143; Package emacs. (Sat, 09 Nov 2019 17:22:01 GMT) Full text and rfc822 format available.

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

From: Óscar Fuentes <ofv <at> wanadoo.es>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: martin rudalics <rudalics <at> gmx.at>, 38143 <at> debbugs.gnu.org
Subject: Re: bug#38143: 27.0.50; Say that before-make-frame-hook &
 after-make-frame-functions are not invoked for the initial frame
Date: Sat, 09 Nov 2019 18:21:40 +0100
Eli Zaretskii <eliz <at> gnu.org> writes:

>>       Note that any functions added to these hooks by your initial file are
>>    usually not run for the initial frame, since Emacs reads the initial
>>    file only after creating that frame.  However, if the initial frame is
>>    specified to use a separate minibuffer frame (*note Minibuffers and
>>    Frames::), the functions will be run for both, the minibuffer-less and
>>    the minibuffer frame.
>> 
>> This explanation is slightly misleading: Since the initial frame is
>> not created by 'make-frame', Emacs would not run these hooks even if
>> it did read the initial file earlier.
>
> But without an init file, where would the hooks come from?
>
> And anyway, the issue is probably only meaningful for users who define
> these hooks in init files.  So I think the only missing piece in the
> above is to mention the daemon case.

Please note that Martin is referring to the manual, not to the
docstrings. Although mentioning the daemon case on the manual would be
nice too.

IMO the missing information on the docstrings is:

1. The hooks are not run for the initial frame because it is not created
   with `make-frame'.

2. Except when Emacs runs as daemon, in that case make-frame is always
   used and therefore the hooks are executed.

The added text would be something like this:

  When Emacs is not executed as a daemon, `make-frame` is not used for
  creating the initial frame, therefore the hooks are not invoked on
  that case.

Or this:

  `make-frame` is not used for the frame that is automatically created
  before the init file is processed, therefore the hooks are not invoked
  for that frame. Please note that when Emacs is executed as a daemon
  there is no such frame.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38143; Package emacs. (Sun, 10 Nov 2019 09:47:03 GMT) Full text and rfc822 format available.

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

From: martin rudalics <rudalics <at> gmx.at>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: ofv <at> wanadoo.es, 38143 <at> debbugs.gnu.org
Subject: Re: bug#38143: 27.0.50; Say that before-make-frame-hook &
 after-make-frame-functions are not invoked for the initial frame
Date: Sun, 10 Nov 2019 10:45:50 +0100
> But without an init file, where would the hooks come from?

From an early-init file.  IIUC that file is read before the initial
frame is created.

martin




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38143; Package emacs. (Thu, 14 Nov 2019 09:48:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: martin rudalics <rudalics <at> gmx.at>
Cc: ofv <at> wanadoo.es, 38143 <at> debbugs.gnu.org
Subject: Re: bug#38143: 27.0.50; Say that before-make-frame-hook &
 after-make-frame-functions are not invoked for the initial frame
Date: Thu, 14 Nov 2019 11:46:47 +0200
> Cc: ofv <at> wanadoo.es, 38143 <at> debbugs.gnu.org
> From: martin rudalics <rudalics <at> gmx.at>
> Date: Sun, 10 Nov 2019 10:45:50 +0100
> 
>  > But without an init file, where would the hooks come from?
> 
> From an early-init file.  IIUC that file is read before the initial
> frame is created.

I'm not sure I understand how this scenario affects the issue at hand
in any significant manner.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38143; Package emacs. (Thu, 14 Nov 2019 10:00:02 GMT) Full text and rfc822 format available.

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

From: martin rudalics <rudalics <at> gmx.at>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: ofv <at> wanadoo.es, 38143 <at> debbugs.gnu.org
Subject: Re: bug#38143: 27.0.50; Say that before-make-frame-hook &
 after-make-frame-functions are not invoked for the initial frame
Date: Thu, 14 Nov 2019 10:59:07 +0100
> I'm not sure I understand how this scenario affects the issue at hand
> in any significant manner.

It doesn't.  It's a related issue I noticed when reading the manual.

martin




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38143; Package emacs. (Sun, 05 Dec 2021 03:14:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Óscar Fuentes <ofv <at> wanadoo.es>
Cc: martin rudalics <rudalics <at> gmx.at>, Eli Zaretskii <eliz <at> gnu.org>,
 38143 <at> debbugs.gnu.org
Subject: Re: bug#38143: 27.0.50; Say that before-make-frame-hook &
 after-make-frame-functions are not invoked for the initial frame
Date: Sun, 05 Dec 2021 04:13:11 +0100
Óscar Fuentes <ofv <at> wanadoo.es> writes:

> 1. The hooks are not run for the initial frame because it is not created
>    with `make-frame'.
>
> 2. Except when Emacs runs as daemon, in that case make-frame is always
>    used and therefore the hooks are executed.
>
> The added text would be something like this:
>
>   When Emacs is not executed as a daemon, `make-frame` is not used for
>   creating the initial frame, therefore the hooks are not invoked on
>   that case.
>
> Or this:
>
>   `make-frame` is not used for the frame that is automatically created
>   before the init file is processed, therefore the hooks are not invoked
>   for that frame. Please note that when Emacs is executed as a daemon
>   there is no such frame.

I've now added something like this to Emacs 29.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug marked as fixed in version 29.1, send any further explanations to 38143 <at> debbugs.gnu.org and Óscar Fuentes <ofv <at> wanadoo.es> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 05 Dec 2021 03:14:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38143; Package emacs. (Sun, 05 Dec 2021 09:48:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: ofv <at> wanadoo.es, rudalics <at> gmx.at, 38143 <at> debbugs.gnu.org
Subject: Re: bug#38143: 27.0.50; Say that before-make-frame-hook &
 after-make-frame-functions are not invoked for the initial frame
Date: Sun, 05 Dec 2021 11:47:00 +0200
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Cc: Eli Zaretskii <eliz <at> gnu.org>,  martin rudalics <rudalics <at> gmx.at>,
>   38143 <at> debbugs.gnu.org
> Date: Sun, 05 Dec 2021 04:13:11 +0100
> 
> Óscar Fuentes <ofv <at> wanadoo.es> writes:
> 
> > 1. The hooks are not run for the initial frame because it is not created
> >    with `make-frame'.
> >
> > 2. Except when Emacs runs as daemon, in that case make-frame is always
> >    used and therefore the hooks are executed.
> >
> > The added text would be something like this:
> >
> >   When Emacs is not executed as a daemon, `make-frame` is not used for
> >   creating the initial frame, therefore the hooks are not invoked on
> >   that case.
> >
> > Or this:
> >
> >   `make-frame` is not used for the frame that is automatically created
> >   before the init file is processed, therefore the hooks are not invoked
> >   for that frame. Please note that when Emacs is executed as a daemon
> >   there is no such frame.
> 
> I've now added something like this to Emacs 29.

Bother:

   (defvar before-make-frame-hook nil
  -  "Functions to run before `make-frame' creates a new frame.")
  +  "Functions to run before `make-frame' creates a new frame.
  +Note that these functions are usually not run for the initial
  +frame, except when the initial frame is created from an Emacs
  +daemon.")

   (defvar after-make-frame-functions nil
     "Functions to run after `make-frame' created a new frame.
   The functions are run with one argument, the newly created
  -frame.")
  +frame.
  +
  +Note that these functions are usually not run for the initial
  +frame, except when the initial frame is created from an Emacs
  +daemon.")

The new text is incorrect -- assuming that by "initial frame" the doc
strings mean what we usually mean by that: the first frame displayed
by a GUI Emacs session (see "Frame Parameters" in the user manual, and
cf. initial-frame-alist).  You can put a breakpoint on Frun_hooks and
on Frun_hook_with_args, run Emacs, and see that both of these hooks
_are_ called during startup.  And the reason is simple: we do create
that "initial frame" via make-frame, see frame-initialize.

Perhaps the bug report was using "initial frame" in another sense: to
allude to the frame we create in temacs, which is a terminal frame,
normally deleted when a GUI session starts, except in a daemon, which
keeps it.  But in that case, these changes will confuse the heck out
of the users who will read them and try to figure out how to use this
information.  We should in that case explain in the doc strings which
"initial frame" we allude to here.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38143; Package emacs. (Sun, 05 Dec 2021 20:18:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: ofv <at> wanadoo.es, rudalics <at> gmx.at, 38143 <at> debbugs.gnu.org
Subject: Re: bug#38143: 27.0.50; Say that before-make-frame-hook &
 after-make-frame-functions are not invoked for the initial frame
Date: Sun, 05 Dec 2021 21:17:01 +0100
Eli Zaretskii <eliz <at> gnu.org> writes:

> The new text is incorrect -- assuming that by "initial frame" the doc
> strings mean what we usually mean by that: the first frame displayed
> by a GUI Emacs session (see "Frame Parameters" in the user manual, and
> cf. initial-frame-alist).

OK; reverted.  Has this changed since the bug was reported?

> Perhaps the bug report was using "initial frame" in another sense: to
> allude to the frame we create in temacs, which is a terminal frame,
> normally deleted when a GUI session starts, except in a daemon, which
> keeps it.  But in that case, these changes will confuse the heck out
> of the users who will read them and try to figure out how to use this
> information.  We should in that case explain in the doc strings which
> "initial frame" we allude to here.

I think we need some input from the bug reported about what they meant
by "initial frame" here.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38143; Package emacs. (Sun, 05 Dec 2021 20:22:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: ofv <at> wanadoo.es, rudalics <at> gmx.at, 38143 <at> debbugs.gnu.org
Subject: Re: bug#38143: 27.0.50; Say that before-make-frame-hook &
 after-make-frame-functions are not invoked for the initial frame
Date: Sun, 05 Dec 2021 22:21:16 +0200
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Cc: ofv <at> wanadoo.es,  rudalics <at> gmx.at,  38143 <at> debbugs.gnu.org
> Date: Sun, 05 Dec 2021 21:17:01 +0100
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> > The new text is incorrect -- assuming that by "initial frame" the doc
> > strings mean what we usually mean by that: the first frame displayed
> > by a GUI Emacs session (see "Frame Parameters" in the user manual, and
> > cf. initial-frame-alist).
> 
> OK; reverted.  Has this changed since the bug was reported?

The only relevant change I know of is that we now have early-init
file, which means users can set up these hooks there, and have them
run when the initial frame is created.

> > Perhaps the bug report was using "initial frame" in another sense: to
> > allude to the frame we create in temacs, which is a terminal frame,
> > normally deleted when a GUI session starts, except in a daemon, which
> > keeps it.  But in that case, these changes will confuse the heck out
> > of the users who will read them and try to figure out how to use this
> > information.  We should in that case explain in the doc strings which
> > "initial frame" we allude to here.
> 
> I think we need some input from the bug reported about what they meant
> by "initial frame" here.

Indeed.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38143; Package emacs. (Mon, 06 Dec 2021 23:23:02 GMT) Full text and rfc822 format available.

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

From: Óscar Fuentes <ofv <at> wanadoo.es>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: rudalics <at> gmx.at, Eli Zaretskii <eliz <at> gnu.org>, 38143 <at> debbugs.gnu.org
Subject: Re: bug#38143: 27.0.50; Say that before-make-frame-hook &
 after-make-frame-functions are not invoked for the initial frame
Date: Tue, 07 Dec 2021 00:22:50 +0100
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Eli Zaretskii <eliz <at> gnu.org> writes:
>
>> The new text is incorrect -- assuming that by "initial frame" the doc
>> strings mean what we usually mean by that: the first frame displayed
>> by a GUI Emacs session (see "Frame Parameters" in the user manual, and
>> cf. initial-frame-alist).
>
> OK; reverted.  Has this changed since the bug was reported?
>
>> Perhaps the bug report was using "initial frame" in another sense: to
>> allude to the frame we create in temacs, which is a terminal frame,
>> normally deleted when a GUI session starts, except in a daemon, which
>> keeps it.  But in that case, these changes will confuse the heck out
>> of the users who will read them and try to figure out how to use this
>> information.  We should in that case explain in the doc strings which
>> "initial frame" we allude to here.
>
> I think we need some input from the bug reported about what they meant
> by "initial frame" here.

I just tested with master and, indeed, the hook is executed. However, to
be effective for all invocations of make-frame the user must add the
function early enough (which means `early-init.el`.) When emacs.el is
processed it is too late as the initial frame (the frame created by
simply invoking emacs without parameters) already exists.

Maybe we could expand the docstrings of the hooks and/or make-frame to
note that you need early-init.el if you want your hooks executed when
the initial frame is created.

Otherwise, this bug can remain closed.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38143; Package emacs. (Tue, 07 Dec 2021 17:59:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Óscar Fuentes <ofv <at> wanadoo.es>
Cc: rudalics <at> gmx.at, larsi <at> gnus.org, 38143-done <at> debbugs.gnu.org
Subject: Re: bug#38143: 27.0.50; Say that before-make-frame-hook &
 after-make-frame-functions are not invoked for the initial frame
Date: Tue, 07 Dec 2021 19:58:33 +0200
> From: Óscar Fuentes <ofv <at> wanadoo.es>
> Cc: Eli Zaretskii <eliz <at> gnu.org>,  rudalics <at> gmx.at,  38143 <at> debbugs.gnu.org
> Date: Tue, 07 Dec 2021 00:22:50 +0100
> 
> > I think we need some input from the bug reported about what they meant
> > by "initial frame" here.
> 
> I just tested with master and, indeed, the hook is executed. However, to
> be effective for all invocations of make-frame the user must add the
> function early enough (which means `early-init.el`.) When emacs.el is
> processed it is too late as the initial frame (the frame created by
> simply invoking emacs without parameters) already exists.
> 
> Maybe we could expand the docstrings of the hooks and/or make-frame to
> note that you need early-init.el if you want your hooks executed when
> the initial frame is created.
> 
> Otherwise, this bug can remain closed.

Done and done.

Thanks.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 05 Jan 2022 12:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 73 days ago.

Previous Next


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