Преглед на файлове

New macro: Wrap let-binding of uninterned SYMBOLS around BODY

* org-macs.el (org-with-gensyms): New macro. Wrap let-binding of
SYMBOLS to new uninterned symbols around BODY.

Use this macro to compose macros that need to bind their own symbols
in expansion. It expands into a let-binding of all symbols in SYMBOLS
to new uninterned symbols that cannot collide with symbols used in the
target macro's expansion.
David Maus преди 14 години
родител
ревизия
4fe8369dae
променени са 1 файла, в които са добавени 6 реда и са изтрити 0 реда
  1. 6 0
      lisp/org-macs.el

+ 6 - 0
lisp/org-macs.el

@@ -47,6 +47,12 @@
 (declare-function org-add-props "org-compat" (string plist &rest props))
 (declare-function org-string-match-p "org-compat" (&rest args))
 
+(defmacro org-with-gensyms (symbols &rest body)
+  `(let ,(mapcar (lambda (s)
+		   `(,s (make-symbol (concat "--" (symbol-name ',s))))) symbols)
+     ,@body))
+(put 'org-with-gensyms 'lisp-indent-function 1)
+
 (defmacro org-called-interactively-p (&optional kind)
   (if (featurep 'xemacs)
        `(interactive-p)