1

I'm trying to bind Command-{ and Command-} to multi-term-prev and multi-term-next. I only want them in term-mode, since if I use it in a file buffer it will switch to show a terminal (which is rather undesirable). As I understand it, Command on Mac is Super inside Emacs by default, so this should work:

(define-key term-mode-map (kbd "s-}") 'multi-term-next)
(define-key term-mode-map (kbd "s-{") 'multi-term-prev)

However, even in a terminal I've verified to be in term-mode, Emacs complains that s-{ and s-} aren't defined (even when using [(super {)] instead of (kbd "s-{")). This works fine as a global keybind:

(global-set-key (kbd "s-}") 'multi-term-next)
(global-set-key (kbd "s-{") 'multi-term-prev)

This is the part of the variable term-mode-map that seems relevant, after the define-keys:

(keymap
  (8388731 . multi-term-prev)
  (8388733 . multi-term-next)
  ...
  (3 keymap
    (17 . term-pager-toggle)
    (10 . term-line-mode)
    (11 . term-char-mode)
    (4 . term-send-eof)
    (16 . term-previous-prompt)
    (14 . term-next-prompt)
    (12 . term-dynamic-list-input-ring)
    (5 . term-show-maximum-output)
    (18 . term-show-output)
    (15 . term-kill-output)
    (13 . term-copy-old-input)
    (28 . term-quit-subjob)
    (26 . term-stop-subjob)
    (3 . term-interrupt-subjob)
    (23 . backward-kill-word)
    (21 . term-kill-input)
    (1 . term-bol))
  (4 . term-delchar-or-maybe-eof)
  (13 . term-send-input)
  (27 keymap
    (12 . term-show-output)
    (4194419 . term-next-matching-input-from-input)
    (4194418 . term-previous-matching-input-from-input)
    (115 . term-next-matching-input)
    (114 . term-previous-matching-input)
    (110 . term-next-input)
    (112 . term-previous-input)))

1 Answers1

3

I think term-mode-map is only used in line-mode. In char-mode, it uses term-raw-map, so try:

(define-key term-raw-map (kbd "s-}") 'multi-term-next)
(define-key term-raw-map (kbd "s-{") 'multi-term-prev)

This does not seem well documented in the docstrings, so I guess you M-x report-emacs-bug to improve the doc.

Stefan
  • 26,154
  • 3
  • 46
  • 84