From: Lars Ingebrigtsen Date: Sun, 17 Oct 2021 17:25:52 +0000 (+0200) Subject: Rewrite kbd-valid-p to not use seq X-Git-Tag: emacs-29.0.90~3671^2~533 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9e46267755e634c49122ea6decffc5b5c5017550;p=emacs.git Rewrite kbd-valid-p to not use seq * lisp/subr.el (kbd-valid-p): Rewrite to not use seq. --- diff --git a/lisp/subr.el b/lisp/subr.el index 6bd3b693b83..635942205b4 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -939,24 +939,27 @@ which is (and (stringp keys) (string-match-p "\\`[^ ]+\\( [^ ]+\\)*\\'" keys) (save-match-data - (seq-every-p - (lambda (key) - ;; Every key might have these modifiers, and they should be - ;; in this order. - (when (string-match - "\\`\\(A-\\)?\\(C-\\)?\\(H-\\)?\\(M-\\)?\\(S-\\)?\\(s-\\)?" - key) - (setq key (substring key (match-end 0)))) - (or (and (= (length key) 1) - ;; Don't accept control characters as keys. - (not (< (aref key 0) ?\s)) - ;; Don't accept Meta'd characters as keys. - (or (multibyte-string-p key) - (not (<= 127 (aref key 0) 255)))) - (string-match-p "\\`<[A-Za-z0-9]+>\\'" key) - (string-match-p - "\\`\\(NUL\\|RET\\|TAB\\|LFD\\|ESC\\|SPC\\|DEL\\)\\'" key))) - (split-string keys " "))))) + (catch 'exit + (dolist (key (split-string keys " ")) + ;; Every key might have these modifiers, and they should be + ;; in this order. + (when (string-match + "\\`\\(A-\\)?\\(C-\\)?\\(H-\\)?\\(M-\\)?\\(S-\\)?\\(s-\\)?" + key) + (setq key (substring key (match-end 0)))) + (unless (or (and (= (length key) 1) + ;; Don't accept control characters as keys. + (not (< (aref key 0) ?\s)) + ;; Don't accept Meta'd characters as keys. + (or (multibyte-string-p key) + (not (<= 127 (aref key 0) 255)))) + (string-match-p "\\`<[A-Za-z0-9]+>\\'" key) + (string-match-p + "\\`\\(NUL\\|RET\\|TAB\\|LFD\\|ESC\\|SPC\\|DEL\\)\\'" + key)) + ;; Invalid. + (throw 'exit nil))) + t)))) (defun kbd (keys &optional need-vector) "Convert KEYS to the internal Emacs key representation.