From 50296843582b13d3e43c4215c7c4e98e44ce650f Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Sun, 17 Oct 2021 21:29:59 +0200 Subject: [PATCH] Reinstate defvar-keymap expansion * lisp/emacs-lisp/byte-opt.el (byte-optimize-define-keymap--define): Make more robust. --- lisp/emacs-lisp/byte-opt.el | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el index aa57e022c5a..abfc9b3b316 100644 --- a/lisp/emacs-lisp/byte-opt.el +++ b/lisp/emacs-lisp/byte-opt.el @@ -1237,14 +1237,17 @@ See Info node `(elisp) Integer Basics'." (defun byte-optimize-define-keymap--define (form) "Expand key bindings in FORM." - (let ((optimized (byte-optimize-define-keymap (nth 1 form)))) - (if (eq optimized (nth 1 form)) - ;; No improvement. - form - (list (car form) optimized)))) - -;;(put 'define-keymap 'byte-optimizer #'byte-optimize-define-keymap) -;;(put 'define-keymap--define 'byte-optimizer #'byte-optimize-define-keymap--define) + (if (not (consp (nth 1 form))) + form + (let ((optimized (byte-optimize-define-keymap (nth 1 form)))) + (if (eq optimized (nth 1 form)) + ;; No improvement. + form + (list (car form) optimized))))) + +(put 'define-keymap 'byte-optimizer #'byte-optimize-define-keymap) +(put 'define-keymap--define 'byte-optimizer + #'byte-optimize-define-keymap--define) ;; I'm not convinced that this is necessary. Doesn't the optimizer loop ;; take care of this? - Jamie -- 2.39.2