emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 3fa6f72: Reverse the edmacro-parse-keys/kbd vector/string logic


From: Lars Ingebrigtsen
Subject: master 3fa6f72: Reverse the edmacro-parse-keys/kbd vector/string logic
Date: Sun, 17 Oct 2021 16:14:48 -0400 (EDT)

branch: master
commit 3fa6f7242316a81f5752e4526d94837f2a90f969
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    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 decb8ed..b3118b0 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 1da453b..07737e2 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 ()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]