From unknown Sun Jun 22 11:46:34 2025 X-Loop: don@donarmstrong.com Subject: bug#1495: emacs -nw inserts unwanted chars if user is impatient Reply-To: Paul R , 1495@debbugs.gnu.org Resent-From: Paul R Resent-To: bug-submit-list@lists.donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Thu, 04 Dec 2008 21:55:04 +0000 Resent-Message-ID: Resent-Sender: don@donarmstrong.com X-Emacs-PR-Message: report 1495 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Received: via spool by submit@emacsbugs.donarmstrong.com id=B.12284271885597 (code B ref -1); Thu, 04 Dec 2008 21:55:04 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.3-bugs.debian.org_2005_01_02 (2007-08-08) on rzlab.ucr.edu X-Spam-Level: X-Spam-Status: No, score=-4.0 required=4.0 tests=BAYES_00 autolearn=ham version=3.2.3-bugs.debian.org_2005_01_02 Received: (at submit) by emacsbugs.donarmstrong.com; 4 Dec 2008 21:46:28 +0000 Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.159]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id mB4LkOGv005591 for ; Thu, 4 Dec 2008 13:46:25 -0800 Received: by fg-out-1718.google.com with SMTP id l27so2897863fgb.43 for ; Thu, 04 Dec 2008 13:46:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:subject:user-agent :package:version:date:message-id:mime-version:content-type; bh=FEPgZwrRwmfiPsR08T3uCQ9a6vvZgwtf15mb+MW8+oE=; b=fbQBSugo0kzEFR3PimcmCcG6dZi9n0YXeRz+QID/FSmEZ8XKUalNgYJcVhnAPMGOdg qtfTTjTZYGLqy8kQMCv3LsB413juGD5M6LXfY5auReAckByJcUbL2QSUB3ClEvMdiQyM TJH2l03GOWJ+erEpurNhH0hglQ8ttDeUZHUrw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:user-agent:package:version:date:message-id :mime-version:content-type; b=Igdi8e1DcnNoPUQCq1bLjne8mGOns/KDAGCn9GG8qgXK8VKfaVEj1Yg4MDfas9rk4H vk8LoCC24Acz1GuSMkZ+Q9tAWNs+3oY5Vs7DUTVEtuCvpeO1qlId52w1dCbPMKEwIerR j2fwjMJBYLerW9R5/3FmnSfRQOJ9o/ioY1ug4= Received: by 10.223.111.205 with SMTP id t13mr720795fap.62.1228427183459; Thu, 04 Dec 2008 13:46:23 -0800 (PST) Received: from ubuT42 (pdc35-1-82-242-132-111.fbx.proxad.net [82.242.132.111]) by mx.google.com with ESMTPS id k29sm15743861fkk.37.2008.12.04.13.46.22 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 04 Dec 2008 13:46:22 -0800 (PST) From: Paul R To: submit@debbugs.gnu.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) Package: emacs Version: 23 Date: Thu, 04 Dec 2008 22:46:20 +0100 Message-ID: <87bpvr8vgz.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Hi, I usually work on X version of emacs 23. However, sometime, I just want to alter a config file from the terminal. In this case I type emacs -nw conf_file.conf Very often I know that the line I want to go to is fairly low so before emacs has finished to load I'm already pressing C-n waiting for the display to show line and point. I guess a lot of user do the same and often don't wait for the display to finish before typing what they want. In this particular case, emacs would insert strange chars at point, for example : 1;1704;0c You won't be warned, and it will be saved along with your real modifications, which is embarassing. To reproduce, open any multiline file from the terminal, for example .bash_history, with 'emacs -nw' and immediatly maintain C-n until the display come up entirely. You should find at point the strange chars. Tested with emacs23cvs with -Q on Gnu/Linux with xterm and gnome-terminal. -- Paul From unknown Sun Jun 22 11:46:34 2025 X-Loop: don@donarmstrong.com Subject: bug#1495: emacs -nw inserts unwanted chars if user is impatient Reply-To: Chong Yidong , 1495@debbugs.gnu.org Resent-From: Chong Yidong Resent-To: bug-submit-list@lists.donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Fri, 05 Dec 2008 04:20:05 +0000 Resent-Message-ID: Resent-Sender: don@donarmstrong.com X-Emacs-PR-Message: report 1495 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Received: via spool by 1495-submit@emacsbugs.donarmstrong.com id=B1495.122845023518072 (code B ref 1495); Fri, 05 Dec 2008 04:20:05 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.3-bugs.debian.org_2005_01_02 (2007-08-08) on rzlab.ucr.edu X-Spam-Level: X-Spam-Status: No, score=-4.0 required=4.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.3-bugs.debian.org_2005_01_02 Received: (at 1495) by emacsbugs.donarmstrong.com; 5 Dec 2008 04:10:35 +0000 Received: from cyd.mit.edu (CYD.MIT.EDU [18.115.2.24]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id mB54AWqT018065 for <1495@emacsbugs.donarmstrong.com>; Thu, 4 Dec 2008 20:10:33 -0800 Received: by cyd.mit.edu (Postfix, from userid 1000) id 23DFE57E1C8; Thu, 4 Dec 2008 23:10:35 -0500 (EST) From: Chong Yidong To: Dan Nicolaescu Cc: Paul R , 1495@debbugs.gnu.org, emacs-devel@gnu.org References: <87ljuv92uq.fsf@gmail.com> <87d4g7d9gn.fsf@cyd.mit.edu> <200812042030.mB4KU5Jn003761@mothra.ics.uci.edu> Date: Thu, 04 Dec 2008 23:10:35 -0500 In-Reply-To: <200812042030.mB4KU5Jn003761@mothra.ics.uci.edu> (Dan Nicolaescu's message of "Thu, 4 Dec 2008 12:30:05 -0800 (PST)") Message-ID: <87skp3w9c4.fsf@cyd.mit.edu> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Dan Nicolaescu writes: > I'm fairly confident this is due to the code in xterm.el that deals > with modifyOtherKeys, the input probably comes while emacs is waiting > from an answer from xterm. This indeed seems to be the problem. Discard pending input before doing the terminal query seems to fix the bug for me. I don't know if it's possible for the user's input to come inat exactly at the correct moment to fool the terminal query; if so, a more complicated solution might be required. Thoughts? *** trunk/lisp/term/xterm.el.~1.59.~ 2008-09-30 20:01:30.000000000 -0400 --- trunk/lisp/term/xterm.el 2008-12-04 23:07:47.000000000 -0500 *************** *** 475,480 **** --- 475,481 ---- (str nil)) ;; Try to find out the type of terminal by sending a "Secondary ;; Device Attributes (DA)" query. + (discard-input) (send-string-to-terminal "\e[>0c") ;; The reply should be of the form: \e [ > NUMBER1 ; NUMBER2 ; NUMBER3 c From unknown Sun Jun 22 11:46:34 2025 X-Loop: don@donarmstrong.com Subject: bug#1495: emacs -nw inserts unwanted chars if user is impatient Reply-To: Stefan Monnier , 1495@debbugs.gnu.org Resent-From: Stefan Monnier Resent-To: bug-submit-list@lists.donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Thu, 11 Dec 2008 16:40:04 +0000 Resent-Message-ID: Resent-Sender: don@donarmstrong.com X-Emacs-PR-Message: report 1495 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Received: via spool by 1495-submit@emacsbugs.donarmstrong.com id=B1495.122901316821194 (code B ref 1495); Thu, 11 Dec 2008 16:40:04 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.3-bugs.debian.org_2005_01_02 (2007-08-08) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.0000 Tokens: new, 34; hammy, 96; neutral, 45; spammy, 1. spammytokens:0.993-1--arguing hammytokens:0.000-+--emacs, 0.000-+--H*M:fsf, 0.000-+--H*UA:Emacs, 0.000-+--H*u:Emacs, 0.000-+--H*UA:Gnus X-Spam-Status: No, score=-5.4 required=4.0 tests=AWL,BAYES_00,MDO_CABLE_TV3 autolearn=no version=3.2.3-bugs.debian.org_2005_01_02 Received: (at 1495) by emacsbugs.donarmstrong.com; 11 Dec 2008 16:32:48 +0000 Received: from ironport2-out.teksavvy.com (ironport2-out.teksavvy.com [206.248.154.182]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id mBBGWj8B021182 for <1495@emacsbugs.donarmstrong.com>; Thu, 11 Dec 2008 08:32:46 -0800 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkcFANbOQElFxIVh/2dsb2JhbACBbMttgnmBLA X-IronPort-AV: E=Sophos;i="4.33,753,1220241600"; d="scan'208";a="30926663" Received: from 69-196-133-97.dsl.teksavvy.com (HELO pastel.home) ([69.196.133.97]) by ironport2-out.teksavvy.com with ESMTP; 11 Dec 2008 11:32:39 -0500 Received: by pastel.home (Postfix, from userid 20848) id C251E86F6; Thu, 11 Dec 2008 11:32:39 -0500 (EST) From: Stefan Monnier To: Chong Yidong Cc: Dan Nicolaescu , 1495@debbugs.gnu.org, Paul R , emacs-devel@gnu.org Message-ID: References: <87ljuv92uq.fsf@gmail.com> <87d4g7d9gn.fsf@cyd.mit.edu> <200812042030.mB4KU5Jn003761@mothra.ics.uci.edu> <87skp3w9c4.fsf@cyd.mit.edu> Date: Thu, 11 Dec 2008 11:32:39 -0500 In-Reply-To: <87skp3w9c4.fsf@cyd.mit.edu> (Chong Yidong's message of "Thu, 04 Dec 2008 23:10:35 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii > Discard pending input before doing the terminal query seems to fix the > bug for me. I don't know if it's possible for the user's input to come > inat exactly at the correct moment to fool the terminal query; if so, a > more complicated solution might be required. While arguing that there's probably no way to do much better than that, it occurred to me that "the right way" to do it might be to move the "check for \e [ > NUMBER1 ; NUMBER2 ; NUMBER3 c and run xterm-turn-on-modify-other-keys if applicable" into the input-decode-map. Stefan