0

I use tabbar in emacs, and bind following key.

(global-set-key (kbd "M-2") 'tabbar-forward-tab)
(global-set-key (kbd "M-1") 'tabbar-backward-tab)

But, those key-binds don't work in ansi-term mode. When I type 'M-1', it do not run tabbar-backward-tab, the key is captured by bash.

[xx@local ~]$ 
(arg: 1) 

How to unbind "M-1" and "M-2" in Emacs ansi-term?

lemon
  • 69
  • 1
  • 9
  • possible duplicate of [Globally override key binding in Emacs](http://stackoverflow.com/questions/683425/globally-override-key-binding-in-emacs) – legoscia Jul 10 '14 at 11:30
  • 1
    When I see people wanting to rebind `M-` (or `C-`) it always makes me think that they're missing the usefulness of numeric prefix arguments, and the convenience of those default bindings. – phils Jul 10 '14 at 12:08
  • @phils You are right, I miss usefulness of numberic prefix arguments, but bind "M-1" on tabbar-backward-tab is more convenient for me. BTW, can we distiguish key ALT and ESC in emacs? – lemon Jul 11 '14 at 04:08

1 Answers1

2

In term-char-mode M-<n> sequences are bound to term-send-raw (as are most sequences which a terminal would normally handle).

To unbind them, you can use:

(eval-after-load "term"
  '(progn
     (define-key term-raw-map (kbd "M-1") nil)
     (define-key term-raw-map (kbd "M-2") nil)))

That will stop them from shadowing the global bindings.

phils
  • 71,335
  • 11
  • 153
  • 198