Reputation: 15854
Here is my attempt:
(global-set-key [M-left] (key-binding (kbd "C-u C-@")))
After I evaluate the above expression, invoking alt
+ left
gives me the message <M-left> is undefined
. The following, however, works:
(global-set-key [M-left] (key-binding (kbd "C-u")))
But this is only the universal argument
part of my command. How do I combine these two commands into one Emacs key-binding?
Upvotes: 1
Views: 963
Reputation: 73345
sds has provided the solutions, but for clarification, if you evaluate (key-binding (kbd "C-u C-@"))
you'll see that it returns nil
-- because that is not a bound key sequence.
In fact C-u runs the command universal-argument
, which takes care of reading a subsequent key sequence from the user (C-@ in your case).
Upvotes: 1
Reputation: 60062
There are two ways to do this: define a Keyboard Macro interactively or write a function:
(define-key global-map [M-left]
(lambda ()
(interactive)
(set-mark-command t)))
Upvotes: 3