GNU bug report logs - #8172
23.2.90; ansi-term mode does not properly handle keystrokes with M- and other modifiers

Previous Next

Package: emacs;

Reported by: Nelson Elhage <nelhage <at> nelhage.com>

Date: Fri, 4 Mar 2011 19:37:01 UTC

Severity: normal

Found in version 23.2.90

Done: Chong Yidong <cyd <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 8172 in the body.
You can then email your comments to 8172 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 owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8172; Package emacs. (Fri, 04 Mar 2011 19:37:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Nelson Elhage <nelhage <at> nelhage.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 04 Mar 2011 19:37:01 GMT) Full text and rfc822 format available.

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

From: Nelson Elhage <nelhage <at> nelhage.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 23.2.90;
	ansi-term mode does not properly handle keystrokes with M- and other
	modifiers
Date: Fri, 04 Mar 2011 14:36:17 -0500
* 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 <backspace> a n s o <tab> <backspace> i <tab> 
t <tab> <return> <return> l s <return> C-v C-M-d <help-echo> 
<M-backspace> <M-backspace> f o o b a r C-a C-v C-M-d 
<help-echo> C-a C-k M-D C-v M-D M-x C-x b <return> 
C-x C-g M-x r e p o r t SPC b u <tab> <return>

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)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#8172; Package emacs. (Wed, 20 Jun 2012 15:26:01 GMT) Full text and rfc822 format available.

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

From: Chong Yidong <cyd <at> gnu.org>
To: Nelson Elhage <nelhage <at> nelhage.com>
Cc: 8172 <at> debbugs.gnu.org
Subject: Re: 23.2.90;
	ansi-term mode does not properly handle keystrokes with M- and other
	modifiers
Date: Wed, 20 Jun 2012 11:22:15 -0400
> * 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.




bug closed, send any further explanations to 8172 <at> debbugs.gnu.org and Nelson Elhage <nelhage <at> nelhage.com> Request was from Chong Yidong <cyd <at> gnu.org> to control <at> debbugs.gnu.org. (Wed, 20 Jun 2012 15:26: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, 19 Jul 2012 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 13 years and 33 days ago.

Previous Next


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