0

I'm on a Mac, using iTerm2. 'Option' is the same as Alt, and Alt is Meta in emacs.

First, in emacs I typed C-h k followed by Option-Up (Hold option key and press up arrow). The output was

ESC <up> (translated from ESC M-[ A) is undefined

So I added this to my .emacs file:

(global-set-key (kbd "<ESC-up>")  'scroll-down-command)

I've also tried

(global-set-key (kbd "M-<up>")  'scroll-down-command)

(Note, scroll-down-command does what I would call scrolling up, and vice versa.)

After reloading .emacs, pressing Option-up gives the following error:

ESC <up> is undefined

Thanks - I'd appreciate any help with this.

Update 1:

I was able to set this interactively using the following:

  1. M-x global-set-key
  2. Press Option + Up-arrow
  3. Enter scroll-down-command

Which worked. Typing C-h k followed by Option + Up-arrow produced the message:

ESC <up> (translated from ESC M-[ A) runs the command scroll-down-command 

I'm still not clear how this differs from what I added to .emacs.

Update 2:

I'm using GNU Emacs 29.1. According to this post, global-set-key is now a legacy function in v29, and the recommended function to use instead is keymap-global-set.

2 Answers 2

0

Use a different syntax for the key:

(global-set-key [M-up] 'scroll-down-command)
1
  • I still get the same error message: ESC <up> is undefined.
    – Chap
    Commented Aug 6, 2023 at 21:48
0

Pre-Emacs-29:

(global-set-key (kbd "ESC <up>") 'scroll-down-command)

Emacs-29:

Use keymap-global-set instead:

(keymap-global-set "ESC <up>"   'scroll-down-command)
(keymap-global-set "ESC <down>" 'scroll-up-command)

Note: keymap-global-set is new as of emacs 29.0, and global-set-key is now a legacy function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.