From 3fa6f7242316a81f5752e4526d94837f2a90f969 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Sun, 17 Oct 2021 22:14:30 +0200 Subject: [PATCH] Reverse the edmacro-parse-keys/kbd vector/string logic * lisp/edmacro.el (edmacro-parse-keys): Convert to a vector if needed. * lisp/subr.el (kbd): Remove the NEED-VECTOR parameter. --- lisp/edmacro.el | 5 ++++- lisp/subr.el | 24 +++++++++--------------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/lisp/edmacro.el b/lisp/edmacro.el index decb8edbb18..b3118b0aa67 100644 --- a/lisp/edmacro.el +++ b/lisp/edmacro.el @@ -640,7 +640,10 @@ This function assumes that the events can be stored in a string." ;;; Parsing a human-readable keyboard macro. (defun edmacro-parse-keys (string &optional need-vector) - (kbd string need-vector)) + (let ((result (kbd string))) + (if (and need-vector (stringp result)) + (seq-into result 'vector) + result))) (provide 'edmacro) diff --git a/lisp/subr.el b/lisp/subr.el index 1da453b30f5..07737e2c08f 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -967,18 +967,14 @@ which is (throw 'exit nil))) t))))) -(defun kbd (keys &optional need-vector) +(defun kbd (keys) "Convert KEYS to the internal Emacs key representation. KEYS should be a string in the format returned by commands such as `C-h k' (`describe-key'). This is the same format used for saving keyboard macros (see `edmacro-mode'). -For an approximate inverse of this, see `key-description'. - -If NEED-VECTOR is non-nil, always return a vector instead of a -string. This is mainly intended for use by `edmacro-parse-keys', -and should normally not be needed." +For an approximate inverse of this, see `key-description'." (declare (pure t) (side-effect-free t)) ;; A pure function is expected to preserve the match data. (save-match-data @@ -1076,15 +1072,13 @@ and should normally not be needed." (setq lres (cdr (cdr lres))) (nreverse lres) lres)))) - (if (and (not need-vector) - (not (memq nil (mapcar (lambda (ch) - (and (numberp ch) - (<= 0 ch 127))) - res)))) - (concat (mapcar (lambda (ch) - (if (= (logand ch ?\M-\^@) 0) - ch (+ ch 128))) - res)) + (if (not (memq nil (mapcar (lambda (ch) + (and (numberp ch) + (<= 0 ch 127))) + res))) + ;; Return a string. + (concat (mapcar #'identity res)) + ;; Return a vector. res)))) (defun undefined () -- 2.39.2