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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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

%d bloggers like this: