]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/emacs-lisp/macroexp.el: Improve last change
authorStefan Monnier <monnier@iro.umontreal.ca>
Thu, 2 Dec 2021 03:51:39 +0000 (22:51 -0500)
committerStefan Monnier <monnier@iro.umontreal.ca>
Thu, 2 Dec 2021 03:51:55 +0000 (22:51 -0500)
Don't burp when `byte-compile-warning-enabled-p` is not yet defined.
And use the call that we had already instead of adding a new one.

(macroexp--warn-wrap): Allow `category`
to be a list to pass to `byte-compile-warning-enabled-p`.
(macroexp-macroexpand): Simplify accordingly.

lisp/emacs-lisp/macroexp.el

index 66c276e7b78b48c2dc4e4150c4ac9d90e8b9a4a2..48d9c680cba35e8342aa87bb6af7595b2e5b5887 100644 (file)
@@ -137,7 +137,9 @@ Other uses risk returning non-nil value that point to the wrong file."
 
 (defun macroexp--warn-wrap (msg form category)
   (let ((when-compiled (lambda ()
-                         (when (byte-compile-warning-enabled-p category)
+                         (when (if (listp category)
+                                   (apply #'byte-compile-warning-enabled-p category)
+                                 (byte-compile-warning-enabled-p category))
                            (byte-compile-warn "%s" msg)))))
     `(progn
        (macroexp--funcall-if-compiled ',when-compiled)
@@ -216,12 +218,11 @@ is executed without being compiled first."
         (let* ((fun (car form))
                (obsolete (get fun 'byte-obsolete-info)))
           (macroexp-warn-and-return
-           (and (byte-compile-warning-enabled-p 'obsolete fun)
-                (macroexp--obsolete-warning
-                 fun obsolete
-                 (if (symbolp (symbol-function fun))
-                     "alias" "macro")))
-           new-form 'obsolete))
+           (macroexp--obsolete-warning
+            fun obsolete
+            (if (symbolp (symbol-function fun))
+                "alias" "macro"))
+           new-form (list 'obsolete fun)))
       new-form)))
 
 (defun macroexp--unfold-lambda (form &optional name)