unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#8172: 23.2.90; ansi-term mode does not properly handle keystrokes with M- and other modifiers
@ 2011-03-04 19:36 Nelson Elhage
  2012-06-20 15:22 ` Chong Yidong
  0 siblings, 1 reply; 2+ messages in thread
From: Nelson Elhage @ 2011-03-04 19:36 UTC (permalink / raw)
  To: 8172

* 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)





^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-06-20 15:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-04 19:36 bug#8172: 23.2.90; ansi-term mode does not properly handle keystrokes with M- and other modifiers Nelson Elhage
2012-06-20 15:22 ` Chong Yidong

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).