From c48bb7deb88317b6beda4c5944aca7998ff8c37a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mattias=20Engdeg=C3=A5rd?= Date: Wed, 29 Jul 2020 17:47:32 +0200 Subject: [PATCH] Preserve match data in 'kbd' * lisp/subr.el (kbd): Preserve match data since this function is declared pure (see discussion in bug#42147). --- lisp/subr.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lisp/subr.el b/lisp/subr.el index 10c37e94134..3c8dbd16146 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -893,8 +893,9 @@ This is the same format used for saving keyboard macros (see For an approximate inverse of this, see `key-description'." ;; Don't use a defalias, since the `pure' property is true only for ;; the calling convention of `kbd'. - (read-kbd-macro keys)) -(put 'kbd 'pure t) + (declare (pure t)) + ;; A pure function is expected to preserve the match data. + (save-match-data (read-kbd-macro keys))) (defun undefined () "Beep to tell the user this binding is undefined." -- 2.39.2