I've enabled the macOS's terminal preference "Use Option as Meta key" but seem unable to have emacs behave in the terminal as it does when running the GUI.
I have the following use-package definition for drag-stuff:
(use-package drag-stuff
:ensure t
:bind (("M-<up>" . drag-stuff-up)
("M-<down>" . drag-stuff-down)))
When running the emacs GUI, option+shift+up/down correctly moves the line(s) up or down as expected.
However, in the terminal (emacs -nw
) the commands are not recognised. The mini buffer says Esc <up> is undefined
or Esc <down> is undefined
.
When I look to describe the key sequence from the terminal I see this:
Esc <up> (translated from Esc M-O A) is undefined
Doing the same in the GUI I'm presented with the following **Help**
window:
<M-up> (translated from <M-S-up>) runs the command drag-stuff-up
(found in global-map), which is an autoloaded interactive Lisp
function in ‘drag-stuff.el’.
It is bound to <M-up>.
[Arg list not available until function definition is loaded.]
Not documented.
I've seen that there are a number of questions on this kind of problem, but I've unfortunately come up short in finding something that works. It seems to be related to Shift+Up isn't recognized by Emacs in a terminal.
If I open the scratch buffer and attempt to see the escape sequence for shift+up
(i.e., key sequence C+q S-up
) I see ^[OA
and similarly ^[OB
for shift+down.
If I include the option (i.e., meta) key I see this for both option+shift+up
and option+shift+down
: ^[
, which is weird.
Any helps on making things as consistent as possible between emacs GUI and NW would be much appreciated. Thanks!
Full emacs.nix
config, for context, is defined here if that helps.