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
+76Lines changed: 76 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -887,6 +887,14 @@ The primary function provided is: ~(datetime-format SYM-OR-FMT &optional TIME &r
887
887
There are several other symbols provided besides ~atom~, such as ~rfc-3339~, which formats dates according to that RFC.
888
888
889
889
** Debugging :debugging:
890
+
:PROPERTIES:
891
+
:TOC: :depth 2 :include descendants
892
+
:END:
893
+
:CONTENTS:
894
+
- [[#tools][Tools]]
895
+
- [[#edebug][Edebug]]
896
+
- [[#debug-warn-macro][debug-warn macro]]
897
+
:END:
890
898
891
899
*** Tools :tools:
892
900
@@ -919,6 +927,74 @@ Declaring ~debug~ forms for functions and macros that take keyword arguments can
919
927
920
928
Probably should first replace the ~:bindings~ part with this, which correctly matches ~let~ bindings: ~(&rest &or symbolp (gate symbolp &optional def-form))~.
921
929
930
+
**** =debug-warn= macro
931
+
932
+
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.
933
+
934
+
For example, when used like:
935
+
936
+
#+BEGIN_SRC elisp :exports code
937
+
(defun argh (var)
938
+
(debug-warn (current-buffer) "This is bad!" (point) var)
939
+
var)
940
+
941
+
(setq warning-minimum-log-level :debug)
942
+
(argh 1)
943
+
#+END_SRC
944
+
945
+
This warning would be shown in the =*Warnings*= buffer:
946
+
947
+
#+BEGIN_EXAMPLE
948
+
Debug (argh): (CURRENT-BUFFER):*scratch* This is bad! (POINT):491845 VAR:1
949
+
#+END_EXAMPLE
950
+
951
+
The macro is not tangled to =epdh.el=, so you may add it to your code as necessary.
952
+
953
+
#+BEGIN_SRC elisp :exports code
954
+
(cl-defmacro debug-warn (&rest args)
955
+
"Display a debug warning showing the runtime value of ARGS.
956
+
The warning automatically includes the name of the containing
957
+
function, and it is only displayed if `warning-minimum-log-level'
958
+
is `:debug' at runtime (which avoids formatting messages that
959
+
won't be shown).
960
+
961
+
Each of ARGS may be a string, which is displayed as-is, or a
962
+
symbol, the value of which is displayed prefixed by its name, or
963
+
a Lisp form, which is displayed prefixed by its first symbol.
964
+
965
+
Before the actual ARGS arguments, you can write keyword
966
+
arguments, i.e. alternating keywords and values. The following
967
+
keywords are supported:
968
+
969
+
:buffer BUFFER Name of buffer to pass to `display-warning'.
970
+
:level LEVEL Level passed to `display-warning', which see.
0 commit comments