From: Lars Ingebrigtsen Date: Sun, 17 Oct 2021 20:14:30 +0000 (+0200) Subject: Reverse the edmacro-parse-keys/kbd vector/string logic X-Git-Tag: emacs-29.0.90~3671^2~526 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=3fa6f7242316a81f5752e4526d94837f2a90f969;p=emacs.git 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. --- 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 ()