فهرست منبع

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)