(defun keymap-set (keymap key definition)
"Set KEY to DEFINITION in KEYMAP.
-KEY is a string that satisfies `key-valid-p'.
+KEY is a string that satisfies `key-valid-p' (or a vector using the
+internal representation of key sequences).
DEFINITION is anything that can be a key's definition:
nil (means key is undefined in this keymap),
or an extended menu item definition.
(See info node `(elisp)Extended Menu Items'.)"
(declare (compiler-macro (lambda (form) (keymap--compile-check key) form)))
- (keymap--check key)
+ (unless (vectorp key) (keymap--check key))
;; If we're binding this key to another key, then parse that other
;; key, too.
(when (stringp definition)
(keymap--check definition)
(setq definition (key-parse definition)))
- (define-key keymap (key-parse key) definition))
+ (define-key keymap (if (vectorp key) key (key-parse key)) definition))
(defun keymap-global-set (key command)
"Give KEY a global binding as COMMAND.
(setq res (vconcat res key))))))
res)))
+(defun key-parse-old-format (keys)
+ "Convert old-style string representation of KEYS to a vector.
+Simpler alternative to the Rube-Goldbergesque composition of
+`key-description' and `key-parse'."
+ (cond
+ ((vectorp keys) keys)
+ ((multibyte-string-p keys) (vconcat keys))
+ ((stringp keys)
+ (vconcat (mapcar (lambda (c) (if (> c 127) (logior (- c 128) ?\M-\0) c))
+ keys)))
+ (t (error "Invalid old-style key sequence: %S" keys))))
+
(defun key-valid-p (keys)
"Say whether KEYS is a valid key.
A key is a string consisting of one or more key strokes.
"<right-margin> <mouse-1>" 'outline-cycle
"<left-margin> S-<mouse-1>" 'outline-cycle-buffer
"<right-margin> S-<mouse-1>" 'outline-cycle-buffer
- (key-description outline-minor-mode-prefix) outline-mode-prefix-map)
+ (key-parse-old-format outline-minor-mode-prefix)
+ outline-mode-prefix-map)
(if outline-minor-mode
(progn
(cond