From unknown Tue Aug 19 06:31:09 2025 X-Loop: help-debbugs@gnu.org Subject: bug#8172: 23.2.90; ansi-term mode does not properly handle keystrokes with M- and other modifiers Resent-From: Nelson Elhage Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 04 Mar 2011 19:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 8172 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 8172@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.129926739113022 (code B ref -1); Fri, 04 Mar 2011 19:37:01 +0000 Received: (at submit) by debbugs.gnu.org; 4 Mar 2011 19:36:31 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Pvanf-0003Nz-3c for submit@debbugs.gnu.org; Fri, 04 Mar 2011 14:36:31 -0500 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Pvand-0003Nk-Ju for submit@debbugs.gnu.org; Fri, 04 Mar 2011 14:36:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PvanX-00039Q-FD for submit@debbugs.gnu.org; Fri, 04 Mar 2011 14:36:24 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, T_RP_MATCHES_RCVD autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([199.232.76.165]:33672) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PvanX-00039M-BQ for submit@debbugs.gnu.org; Fri, 04 Mar 2011 14:36:23 -0500 Received: from [140.186.70.92] (port=42745 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PvanW-0006UO-BZ for bug-gnu-emacs@gnu.org; Fri, 04 Mar 2011 14:36:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PvanU-00038T-Ti for bug-gnu-emacs@gnu.org; Fri, 04 Mar 2011 14:36:22 -0500 Received: from dmz-mailsec-scanner-8.mit.edu ([18.7.68.37]:55475) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PvanU-00038M-Rt for bug-gnu-emacs@gnu.org; Fri, 04 Mar 2011 14:36:20 -0500 X-AuditID: 12074425-b7c98ae000000a04-b3-4d713f337964 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) by dmz-mailsec-scanner-8.mit.edu (Symantec Brightmail Gateway) with SMTP id 1F.A3.02564.33F317D4; Fri, 4 Mar 2011 14:36:20 -0500 (EST) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id p24JaJnt009253 for ; Fri, 4 Mar 2011 14:36:19 -0500 Received: from localhost (c-174-63-12-109.hsd1.ma.comcast.net [174.63.12.109]) (authenticated bits=0) (User authenticated as nelhage@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id p24JaH7i024574 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT) for ; Fri, 4 Mar 2011 14:36:18 -0500 (EST) From: Nelson Elhage Date: Fri, 04 Mar 2011 14:36:17 -0500 Message-ID: <87k4ge1xvy.fsf@mit.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Brightmail-Tracker: AAAAAReP6oI= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 199.232.76.165 X-Spam-Score: -6.0 (------) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.0 (------) * Run M-x ansi-term * Type a key combination including Meta and either Ctrl or Shift. * The shell inside ansi-term will receive it with the control or shift dropped. You can verify this by e.g. trying C-v C-M-a into bash; The expected behavior is that bash prints ^[ and then moves to the beginning of the line; Inside ansi-term, it prints ^[a, since the C- gets dropped. This even happens with "shift", so M-D gets sent as "ESC d". The bug is caused by `term-send-raw-meta`, which sends an ESC followed by (essentially) (event-basic-type last-input-event), which also strips all the other modifiers, not just M-./ The following patch fixes the issue for me, but I am not sure it is correct in general. diff --git a/lisp/term.el b/lisp/term.el index 2223ff2..28a4aa6 100644 --- a/lisp/term.el +++ b/lisp/term.el @@ -1218,7 +1218,7 @@ without any interpretation." (setq tmp (get char 'ascii-character)) (when tmp (setq char tmp))))) - (setq char (event-basic-type char)) + (setq char (logand char (lognot ?\M-\^@))) (term-send-raw-string (if (and (numberp char) (> char 127) (< char 256)) In GNU Emacs 23.2.90.1 (x86_64-unknown-linux-gnu, X toolkit, Xaw3d scroll bars) of 2010-11-09 on psychotique Windowing system distributor `The X.Org Foundation', version 11.0.10706000 configured using `configure '--prefix' '/home/nelhage/sw/emacs' '--with-x-toolkit=lucid'' Important settings: value of $LC_ALL: nil value of $LC_COLLATE: nil value of $LC_CTYPE: nil value of $LC_MESSAGES: nil value of $LC_MONETARY: nil value of $LC_NUMERIC: nil value of $LC_TIME: nil value of $LANG: en_US.utf8 value of $XMODIFIERS: nil locale-coding-system: utf-8-unix default enable-multibyte-characters: t Major mode: Fundamental Minor modes in effect: tooltip-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t blink-cursor-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Recent input: M-x n a n s o i t l s C-v C-M-d f o o b a r C-a C-v C-M-d C-a C-k M-D C-v M-D M-x C-x b C-x C-g M-x r e p o r t SPC b u Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. Load-path shadows: None found. Features: (shadow sort mail-extr message sendmail regexp-opt ecomplete rfc822 mml easymenu mml-sec password-cache mm-decode mm-bodies mm-encode mailcap mail-parse rfc2231 rfc2047 rfc2045 qp ietf-drums mailabbrev nnheader gnus-util netrc time-date mm-util mail-prsvr gmm-utils wid-edit mailheader canlock sha1 hex-util hashcash mail-utils emacsbug term disp-table ehelp electric ring tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd font-setting tool-bar dnd fontset image fringe lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar mldrag mouse jit-lock font-lock syntax facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev loaddefs button minibuffer faces cus-face files text-properties overlay md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote make-network-process dbusbind system-font-setting font-render-setting x-toolkit x multi-tty emacs) From unknown Tue Aug 19 06:31:09 2025 X-Loop: help-debbugs@gnu.org Subject: bug#8172: 23.2.90; ansi-term mode does not properly handle keystrokes with M- and other modifiers References: <87k4ge1xvy.fsf@mit.edu> In-Reply-To: <87k4ge1xvy.fsf@mit.edu> Resent-From: Chong Yidong Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 20 Jun 2012 15:26:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 8172 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Nelson Elhage Cc: 8172@debbugs.gnu.org Received: via spool by 8172-submit@debbugs.gnu.org id=B8172.134020594723115 (code B ref 8172); Wed, 20 Jun 2012 15:26:01 +0000 Received: (at 8172) by debbugs.gnu.org; 20 Jun 2012 15:25:47 +0000 Received: from localhost ([127.0.0.1]:50001 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1ShMmw-00060l-Rs for submit@debbugs.gnu.org; Wed, 20 Jun 2012 11:25:47 -0400 Received: from fencepost.gnu.org ([208.118.235.10]:48072) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1ShMmv-00060e-6r for 8172@debbugs.gnu.org; Wed, 20 Jun 2012 11:25:46 -0400 Received: from cyd by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1ShMjX-0005XY-DR; Wed, 20 Jun 2012 11:22:15 -0400 From: Chong Yidong Date: Wed, 20 Jun 2012 11:22:15 -0400 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -6.9 (------) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) > * Run M-x ansi-term > * Type a key combination including Meta and either Ctrl or Shift. > * The shell inside ansi-term will receive it with the control or shift > dropped. > > The following patch fixes the issue for me, but I am not sure it is > correct in general. Thank you for the bug report, and for the patch. I've committed a slightly different fix into trunk. From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 20 11:25:56 2012 Received: (at control) by debbugs.gnu.org; 20 Jun 2012 15:25:56 +0000 Received: from localhost ([127.0.0.1]:50004 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1ShMn5-000615-Fs for submit@debbugs.gnu.org; Wed, 20 Jun 2012 11:25:56 -0400 Received: from fencepost.gnu.org ([208.118.235.10]:48074) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1ShMn3-00060y-PN for control@debbugs.gnu.org; Wed, 20 Jun 2012 11:25:53 -0400 Received: from cyd by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1ShMjh-0005Xw-Rh for control@debbugs.gnu.org; Wed, 20 Jun 2012 11:22:25 -0400 From: Chong Yidong To: control@debbugs.gnu.org Subject: close 8172 Date: Wed, 20 Jun 2012 11:22:25 -0400 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -6.9 (------) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) close 8172 thanks