简体   繁体   中英

How to unbind “M-1” and “M-2” in Emacs ansi-term

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM