emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] scratch/with-suppressed-warnings 35719fe 2/2: Use byte-com


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] scratch/with-suppressed-warnings 35719fe 2/2: Use byte-compile-initial-macro-environment to avoid intermediary function
Date: Sun, 9 Jun 2019 09:52:39 -0400 (EDT)

branch: scratch/with-suppressed-warnings
commit 35719fe14ae90fc62bd4c6ce31783a5e79275e54
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    Use byte-compile-initial-macro-environment to avoid intermediary function
---
 lisp/emacs-lisp/byte-run.el | 14 ++++----------
 lisp/emacs-lisp/bytecomp.el | 19 ++++++++++++++++---
 2 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el
index 9a9d933..e9a9e66 100644
--- a/lisp/emacs-lisp/byte-run.el
+++ b/lisp/emacs-lisp/byte-run.el
@@ -494,17 +494,11 @@ is enabled."
   ;; The implementation for the interpreter is basically trivial.
   (car (last body)))
 
-(defmacro with-suppressed-warnings (warnings &rest body)
-  "Like `progn', but prevents compiler warnings in the body."
-  (declare (indent 1))
+(defmacro with-suppressed-warnings (_warnings &rest body)
+  "Like `progn', but prevents compiler WARNINGS in BODY."
+  (declare (debug (sexp &optional body)) (indent 1))
   ;; The implementation for the interpreter is basically trivial.
-  `(with-suppressed-warnings-1 ',warnings (progn ,@body)))
-
-(defun with-suppressed-warnings-1 (_ &rest body)
-  "Like `progn', but prevents compiler warnings in the body."
-  (declare (indent 1))
-  ;; The implementation for the interpreter is basically trivial.
-  (car (last body)))
+  `(progn ,@body))
 
 
 (defun byte-run--unescaped-character-literals-warning ()
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 4d14327..b684c98 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -510,7 +510,12 @@ Return the compile-time value of FORM."
                                       form
                                       macroexpand-all-environment)))
                                 (eval expanded lexical-binding)
-                                expanded))))))
+                                expanded)))))
+    (with-suppressed-warnings
+        . (lambda (warnings &rest body)
+            (macroexpand-all `(internal--with-suppressed-warnings
+                               ',warnings ,@body)
+                             macroexpand-all-environment))))
   "The default macro-environment passed to macroexpand by the compiler.
 Placing a macro here will cause a macro to have different semantics when
 expanded by the compiler as when expanded by the interpreter.")
@@ -2528,7 +2533,15 @@ list that represents a doc string reference.
     (mapc 'byte-compile-file-form (cdr form))
     nil))
 
-(put 'with-suppressed-warnings-1 'byte-hunk-handler
+(defun internal--with-suppressed-warnings (_ &rest body)
+  "Placeholder function used to connect between macro and byte compilation.
+`byte-compile-initial-macro-environment' maps
+`with-suppressed-warnings' to
+`internal--with-suppressed-warnings', and the `byte-hunk-handler'
+for that function basically turns it into a `progn'."
+  (car (last body)))
+
+(put 'internal--with-suppressed-warnings 'byte-hunk-handler
      'byte-compile-file-form-with-suppressed-warnings)
 (defun byte-compile-file-form-with-suppressed-warnings (form)
   ;; cf byte-compile-file-form-progn.
@@ -4783,7 +4796,7 @@ binding slots have been popped."
   (let (byte-compile-warnings)
     (byte-compile-form (cons 'progn (cdr form)))))
 
-(byte-defop-compiler-1 with-suppressed-warnings-1
+(byte-defop-compiler-1 internal--with-suppressed-warnings
                        byte-compile-suppressed-warnings)
 (defun byte-compile-suppressed-warnings (form)
   (let ((byte-compile-suppressed-warnings



reply via email to

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