emacs-libvterm vs. macOS vs. M-p


I use ace-window, mapped to M-p. I wanted to use M-p in the vterm window and not have the sequence sent to the terminal.

The intersection of macOS’ processing of the escape key vs. Emacs proved to be a challenge.

Here’s the solution, courtesy of Gabriele Bozzola.

;; emacs-vterm, a terminal that's better than the other terminals.
(use-package vterm
  :ensure t
  :config
  (setq vterm-max-scrollback 20000)
  ;; We want to use M-p in the vterm window.  On macOS we have to do both of these.
  (define-key vterm-mode-map (kbd "<escape>") nil)
  (define-key vterm-mode-map (kbd "M-p") nil)
  (global-set-key "\M-\S-T" 'vterm)
  )

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.