diff --git a/elisp-to-cl-lesson.org b/elisp-to-cl-lesson.org index 6453fb9..9dc893d 100644 --- a/elisp-to-cl-lesson.org +++ b/elisp-to-cl-lesson.org @@ -2175,6 +2175,31 @@ Item 5 is ? (HOW DO YOU DO ?) #+end_src +* [[http://random-state.net/log/3390120648.html][Why I like CALL-WITH-* style in macros]] +:PROPERTIES: +:CUSTOM_ID: sec:call-with-macros +:END: + +Listing [[lst]] The post [[https://lists.gnu.org/archive/html/emacs-devel/2023-12/msg00683.html][João Távora: permanently fix org breakage during builds]] +links to the origin of the code in listing [[lst:call-with-macros]]. + +BUG: make a concrete ~CALL-WITH-*~ macro example. + +#+caption[Abstract "CALL-WITH-*" macro example]: +#+caption: Abstract ~CALL-WITH-*~ macro example. +#+caption: with variable clauses, exit clauses, and a body. +#+name: lst:call-with-macros +#+begin_src emacs-lisp -n :eval never +(defmacro with-foo ((foo) &body body) + `(call-with-foo (lambda (,foo) ,@body))) + +(defun call-with-foo (function) + (let (foo) + (unwind-protect + (funcall function (setf foo (get-foo))) + (when foo (release-foo foo))))) +#+end_src + * Local variables :noexport: # Emacs looks for "Local variables:" after the last "newline-formfeed".