You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.org
+39-12Lines changed: 39 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -958,16 +958,18 @@ Probably should first replace the ~:bindings~ part with this, which correctly ma
958
958
959
959
**** =debug-warn= macro
960
960
961
-
This macro simplifies print-style debugging by automatically including the names of the containing function and argument forms, rather than requiring the programmer to write =format= strings manually.
961
+
This macro simplifies print-style debugging by automatically including the names of the containing function and argument forms, rather than requiring the programmer to write =format= strings manually. If ~warning-minimum-log-level~ is not ~:debug~ at expansion time, the macro expands to nil, which the byte-compiler eliminates, therefore the macro has no overhead at runtime when not debugging. When debugging, the expanded form also returns nil so, e.g. it may be used in a conditional in place of nil. The macro is tangled to =epdh.el=, but it may also be added directly to source files.
962
962
963
963
For example, when used like:
964
964
965
965
#+BEGIN_SRC elisp :exports code
966
+
(eval-and-compile
967
+
(setq-local warning-minimum-log-level :debug))
968
+
966
969
(defun argh (var)
967
970
(debug-warn (current-buffer) "This is bad!" (point) var)
968
971
var)
969
972
970
-
(setq warning-minimum-log-level :debug)
971
973
(argh 1)
972
974
#+END_SRC
973
975
@@ -977,15 +979,38 @@ This warning would be shown in the =*Warnings*= buffer:
977
979
Debug (argh): (CURRENT-BUFFER):*scratch* This is bad! (POINT):491845 VAR:1
978
980
#+END_EXAMPLE
979
981
980
-
The macro is not tangled to =epdh.el=, so you may add it to your code as necessary.
982
+
But if ~warning-minimum-log-level~ had any other value, and the buffer were recompiled, there would be no output, and none of the arguments to the macro would be evaluated at runtime.
981
983
982
-
#+BEGIN_SRC elisp :exports code
983
-
(cl-defmacro debug-warn (&rest args)
984
+
It may even be used in place of comments! For example, instead of:
0 commit comments