From unknown Fri Aug 15 01:55:14 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#16859 <16859@debbugs.gnu.org> To: bug#16859 <16859@debbugs.gnu.org> Subject: Status: tty-setup-hook can run twice Reply-To: bug#16859 <16859@debbugs.gnu.org> Date: Fri, 15 Aug 2025 08:55:14 +0000 retitle 16859 tty-setup-hook can run twice reassign 16859 emacs submitter 16859 Glenn Morris severity 16859 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 23 20:39:29 2014 Received: (at submit) by debbugs.gnu.org; 24 Feb 2014 01:39:29 +0000 Received: from localhost ([127.0.0.1]:37093 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WHkW1-00012v-5z for submit@debbugs.gnu.org; Sun, 23 Feb 2014 20:39:29 -0500 Received: from fencepost.gnu.org ([208.118.235.10]:39662 ident=Debian-exim) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WHkVx-00012k-Jy for submit@debbugs.gnu.org; Sun, 23 Feb 2014 20:39:26 -0500 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1WHkVw-0001u6-Th; Sun, 23 Feb 2014 20:39:24 -0500 From: Glenn Morris To: submit@debbugs.gnu.org Subject: tty-setup-hook can run twice X-Spook: UNSCOM Kh-11 Mole Compsec sweep Bin Laden plutonium bemd X-Ran: o7n*d?G$f40&(^9(Uz>MYm2\]4a:]{;~A7~aPZBZ(m(R#\R/WS*0ek:qz#Vto X-Hue: magenta X-Debbugs-No-Ack: yes X-Attribution: GM Date: Sun, 23 Feb 2014 20:39:24 -0500 Message-ID: User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -5.5 (-----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.5 (-----) 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 <| /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. From debbugs-submit-bounces@debbugs.gnu.org Tue Feb 25 04:07:01 2014 Received: (at 16859) by debbugs.gnu.org; 25 Feb 2014 09:07:01 +0000 Received: from localhost ([127.0.0.1]:38575 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WIDye-000410-CL for submit@debbugs.gnu.org; Tue, 25 Feb 2014 04:07:01 -0500 Received: from fencepost.gnu.org ([208.118.235.10]:41233 ident=Debian-exim) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WIDyZ-00040q-Rw for 16859@debbugs.gnu.org; Tue, 25 Feb 2014 04:06:56 -0500 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1WIDyY-0001hl-08; Tue, 25 Feb 2014 04:06:54 -0500 From: Glenn Morris To: 16859@debbugs.gnu.org Subject: Re: bug#16859: tty-setup-hook can run twice References: X-Spook: Hugo Chavez AIMSX CBNRC CipherTAC-2000 Majic bullion NSA X-Ran: l;kCgjzO6%C2RM!0xil/ez'St{>k5Eg$!FzDOCiqOw|_|GYG9HCu,H0T*N283t+F)XZ?fZ X-Hue: black X-Debbugs-No-Ack: yes X-Attribution: GM Date: Tue, 25 Feb 2014 04:06:53 -0500 In-Reply-To: (Glenn Morris's message of "Sun, 23 Feb 2014 20:39:24 -0500") Message-ID: User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 16859 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) 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. From debbugs-submit-bounces@debbugs.gnu.org Tue Feb 25 17:02:26 2014 Received: (at 16859) by debbugs.gnu.org; 25 Feb 2014 22:02:26 +0000 Received: from localhost ([127.0.0.1]:40018 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WIQ54-00026B-Em for submit@debbugs.gnu.org; Tue, 25 Feb 2014 17:02:26 -0500 Received: from mercure.iro.umontreal.ca ([132.204.24.67]:49729) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WIQ53-000264-6J for 16859@debbugs.gnu.org; Tue, 25 Feb 2014 17:02:25 -0500 Received: from hidalgo.iro.umontreal.ca (hidalgo.iro.umontreal.ca [132.204.27.50]) by mercure.iro.umontreal.ca (Postfix) with ESMTP id C217684C1C; Tue, 25 Feb 2014 17:02:24 -0500 (EST) Received: from lechon.iro.umontreal.ca (lechon.iro.umontreal.ca [132.204.27.242]) by hidalgo.iro.umontreal.ca (Postfix) with ESMTP id AF57D1E5874; Tue, 25 Feb 2014 17:01:58 -0500 (EST) Received: by lechon.iro.umontreal.ca (Postfix, from userid 20848) id 80358B4128; Tue, 25 Feb 2014 17:01:58 -0500 (EST) From: Stefan Monnier To: Glenn Morris Subject: Re: bug#16859: tty-setup-hook can run twice Message-ID: References: Date: Tue, 25 Feb 2014 17:01:58 -0500 In-Reply-To: (Glenn Morris's message of "Tue, 25 Feb 2014 04:06:53 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-DIRO-MailScanner-Information: Please contact the ISP for more information X-DIRO-MailScanner: Found to be clean X-DIRO-MailScanner-SpamCheck: n'est pas un polluriel, SpamAssassin (score=-2.82, requis 5, autolearn=not spam, ALL_TRUSTED -2.82, MC_TSTLAST 0.00) X-DIRO-MailScanner-From: monnier@iro.umontreal.ca X-Spam-Status: No X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 16859 Cc: 16859@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) > 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 From debbugs-submit-bounces@debbugs.gnu.org Tue Feb 25 17:24:42 2014 Received: (at 16859) by debbugs.gnu.org; 25 Feb 2014 22:24:42 +0000 Received: from localhost ([127.0.0.1]:40026 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WIQQb-0003rS-EM for submit@debbugs.gnu.org; Tue, 25 Feb 2014 17:24:41 -0500 Received: from fencepost.gnu.org ([208.118.235.10]:56278) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WIQQZ-0003rL-FF for 16859@debbugs.gnu.org; Tue, 25 Feb 2014 17:24:39 -0500 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1WIQQY-00023o-Hw; Tue, 25 Feb 2014 17:24:38 -0500 From: Glenn Morris To: Stefan Monnier Subject: Re: bug#16859: tty-setup-hook can run twice References: X-Spook: USDOJ Skipjack bomb Armani Sears Tower SAFE satellite X-Ran: v>;/f`HGz{_%B-]#vT9M}>*;.noJ User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -4.3 (----) X-Debbugs-Envelope-To: 16859 Cc: 16859@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.3 (----) 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? From debbugs-submit-bounces@debbugs.gnu.org Wed Feb 26 10:55:48 2014 Received: (at 16859) by debbugs.gnu.org; 26 Feb 2014 15:55:48 +0000 Received: from localhost ([127.0.0.1]:41469 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WIgpn-00013j-3N for submit@debbugs.gnu.org; Wed, 26 Feb 2014 10:55:47 -0500 Received: from ironport2-out.teksavvy.com ([206.248.154.181]:45481) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WIgpk-00013b-Dc for 16859@debbugs.gnu.org; Wed, 26 Feb 2014 10:55:44 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av4EABK/CFFFpaMk/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLDiYSFBgNJIgeBsEtkQoDiGGcGYFegxU X-IPAS-Result: Av4EABK/CFFFpaMk/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLDiYSFBgNJIgeBsEtkQoDiGGcGYFegxU X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="48806980" Received: from 69-165-163-36.dsl.teksavvy.com (HELO pastel.home) ([69.165.163.36]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 26 Feb 2014 10:55:43 -0500 Received: by pastel.home (Postfix, from userid 20848) id 99DEB601A0; Wed, 26 Feb 2014 10:55:43 -0500 (EST) From: Stefan Monnier To: Glenn Morris Subject: Re: bug#16859: tty-setup-hook can run twice Message-ID: References: Date: Wed, 26 Feb 2014 10:55:43 -0500 In-Reply-To: (Glenn Morris's message of "Tue, 25 Feb 2014 17:24:38 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 16859 Cc: 16859@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) > 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 From debbugs-submit-bounces@debbugs.gnu.org Wed Feb 26 14:41:41 2014 Received: (at control) by debbugs.gnu.org; 26 Feb 2014 19:41:41 +0000 Received: from localhost ([127.0.0.1]:41800 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WIkMO-0002jC-FH for submit@debbugs.gnu.org; Wed, 26 Feb 2014 14:41:40 -0500 Received: from fencepost.gnu.org ([208.118.235.10]:49666) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WIkML-0002j1-KJ for control@debbugs.gnu.org; Wed, 26 Feb 2014 14:41:38 -0500 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1WIkML-00029u-3k for control@debbugs.gnu.org; Wed, 26 Feb 2014 14:41:37 -0500 Date: Wed, 26 Feb 2014 14:41:37 -0500 Message-Id: Subject: control message for bug 16859 To: X-Mailer: mail (GNU Mailutils 2.1) From: Glenn Morris X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) close 16859 24.4 From unknown Fri Aug 15 01:55:14 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 27 Mar 2014 11:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator