GNU bug report logs - #16859
tty-setup-hook can run twice

Previous Next

Package: emacs;

Reported by: Glenn Morris <rgm <at> gnu.org>

Date: Mon, 24 Feb 2014 01:40:02 UTC

Severity: normal

Found in version 24.3.50

Fixed in version 24.4

Done: Glenn Morris <rgm <at> gnu.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 16859 in the body.
You can then email your comments to 16859 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#16859; Package emacs. (Mon, 24 Feb 2014 01:40:03 GMT) Full text and rfc822 format available.

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

From: Glenn Morris <rgm <at> gnu.org>
To: submit <at> debbugs.gnu.org
Subject: tty-setup-hook can run twice
Date: Sun, 23 Feb 2014 20:39:24 -0500
Package: emacs
Version: 24.3.50

Current trunk on GNU/Linux.
I don't know if this matters, but tty-setup-hook can run twice.

From an xterm:

export TERM=xterm
export COLORTERM=rxvt

cat <<EOF >| /tmp/.emacs
(add-hook 'tty-setup-hook (lambda () (message "hi")))
EOF

HOME=/tmp ./src/emacs -nw
C-h e
  -> hi [2 times]

This is because tty-run-terminal-initialization runs terminal-init-xterm,
which in this case calls tty-run-terminal-initialization again with type
"rxvt".

Since several of the other init functions in term/ run
tty-run-terminal-initialization, this could happen with other terminal
types as well.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16859; Package emacs. (Tue, 25 Feb 2014 09:07:03 GMT) Full text and rfc822 format available.

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

From: Glenn Morris <rgm <at> gnu.org>
To: 16859 <at> debbugs.gnu.org
Subject: Re: bug#16859: tty-setup-hook can run twice
Date: Tue, 25 Feb 2014 04:06:53 -0500
Possible solutions:

1) Let-bind tty-setup-hook to nil round all calls to
tty-run-terminal-initialization in term/*.el.

2) Move running of tty-setup-hook out of tty-run-terminal-initialization,
into tty-create-frame-with-faces and command-line.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16859; Package emacs. (Tue, 25 Feb 2014 22:03:01 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 16859 <at> debbugs.gnu.org
Subject: Re: bug#16859: tty-setup-hook can run twice
Date: Tue, 25 Feb 2014 17:01:58 -0500
> 1) Let-bind tty-setup-hook to nil round all calls to
> tty-run-terminal-initialization in term/*.el.

I don't like let-binding hooks (e.g. it doesn't work right when the hook
has both a global and a buffer-local value).

> 2) Move running of tty-setup-hook out of tty-run-terminal-initialization,
> into tty-create-frame-with-faces and command-line.

I haven't looked at it, but it sounds preferable, yes,


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16859; Package emacs. (Tue, 25 Feb 2014 22:25:02 GMT) Full text and rfc822 format available.

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

From: Glenn Morris <rgm <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 16859 <at> debbugs.gnu.org
Subject: Re: bug#16859: tty-setup-hook can run twice
Date: Tue, 25 Feb 2014 17:24:38 -0500
Stefan Monnier wrote:

>> 1) Let-bind tty-setup-hook to nil round all calls to
>> tty-run-terminal-initialization in term/*.el.
>
> I don't like let-binding hooks (e.g. it doesn't work right when the hook
> has both a global and a buffer-local value).
>
>> 2) Move running of tty-setup-hook out of tty-run-terminal-initialization,
>> into tty-create-frame-with-faces and command-line.
>
> I haven't looked at it, but it sounds preferable, yes,

Or you can have option 3:

3) Add optional DO-NOT-RUN-HOOK (or the inverse) argument to
tty-run-terminal-initialization.


BTW, I also noticed that the hook runs when emacs --daemon is started,
which seems odd?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16859; Package emacs. (Wed, 26 Feb 2014 15:56:01 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 16859 <at> debbugs.gnu.org
Subject: Re: bug#16859: tty-setup-hook can run twice
Date: Wed, 26 Feb 2014 10:55:43 -0500
> 3) Add optional DO-NOT-RUN-HOOK (or the inverse) argument to
> tty-run-terminal-initialization.

I guess for backward compatibility's sake, adding a RUN-HOOK is a good idea.

> BTW, I also noticed that the hook runs when emacs --daemon is started,
> which seems odd?

Indeed, since we do

  (unless (or noninteractive
              initial-window-system)
    (tty-run-terminal-initialization (selected-frame)))

it would make sense to also prevent tty-run-terminal-initialization when
in daemon (tho I thought `noninteractive' would be set for daemon, but
maybe this is run late enough that `noninteractive' has already been
changed to nil by then).


        Stefan




bug marked as fixed in version 24.4, send any further explanations to 16859 <at> debbugs.gnu.org and Glenn Morris <rgm <at> gnu.org> Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Wed, 26 Feb 2014 19:42:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 27 Mar 2014 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 27 days ago.

Previous Next


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