Is it somehow possible to set multiple keys with global-set-key without having to repeat the statement, like setting multiple variables with setq?
1 Answer
In a word, no. C-h f global-set-key tells you what the function's signature is:
global-set-keyis an interactive compiled Lisp function insubr.el.
(global-set-key KEY COMMAND)Give
KEYa global binding asCOMMAND....
The function accepts only a single key sequence and a single command.
If you really wanted to save multiple occurrences of the text (global-set-key and ) then you could write a function to do that. E.g.:
(defun my-g-s-k (&rest k+c)
"..."
(let (key cmd)
(while k+c
(global-set-key (car k+c) (cadr k+c))
(setq k+c (cddr k+c)))))
(my-g-s-k "\C-o" 'forward-char
"\M-o" 'backward-char
"\C-\M-o" 'forward-line)