Reputation: 3364
I want to change the commands for setting bookmarks, listing them and finding them in emacs. This is the emacs lisp code I have tried:
(global-set-key (kbd "C-c C-z") (kbd "C-x r m"))
This is failing. What is the correct method?
Upvotes: 1
Views: 772
Reputation: 60004
If you want to define a key to do what some other key does, you want to do
(global-set-key (kbd "C-c C-z") (global-key-binding (kbd "C-x r m")))
If then you can rebind C-x r m to something else and C-c C-z will still be bound to bookmark-set
(this is similar to file copying).
If, on the other hand, you want to make C-c C-z an alias for C-x r m, you need to use function-key-map
:
(define-key function-key-map (kbd "C-c C-z") (kbd "C-x r m"))
in which case C-c C-z will be doing whatever C-x r m is doing even if you rebind the latter (this is similar to symbolic file links).
Upvotes: 4
Reputation: 20342
You should make use of Emacs' extensive help system:
global-set-key
to get information
on how it should be called.Upvotes: 1
Reputation: 400204
The second argument of global-set-key
needs to be the symbol of the function you want to run. In your case, the command C-x r m
ordinarily corresponds to the bookmark-set
(I determined this by running C-x k C-x r m
), so you should pass 'bookmark-set
:
(global-set-key (kbd "C-c C-z") 'bookmark-set)
Upvotes: 2