summary refs log tree commit diff stats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/compat.el17
1 files changed, 17 insertions, 0 deletions
diff --git a/lisp/compat.el b/lisp/compat.el index 0cc4c42..4bb8706 100644 --- a/lisp/compat.el +++ b/lisp/compat.el
@@ -13,5 +13,22 @@
13(dolist (file (directory-files (locate-user-emacs-file "lisp/compat") :full "\\.el\\'")) 13(dolist (file (directory-files (locate-user-emacs-file "lisp/compat") :full "\\.el\\'"))
14 (load file :noerror)) 14 (load file :noerror))
15 15
16;; Other stuff...
17
18(unless (fboundp 'dlet)
19 (defmacro dlet (binders &rest body)
20 "Like `let' but using dynamic scoping."
21 (declare (indent 1) (debug let))
22 ;; (defvar FOO) only affects the current scope, but in order for
23 ;; this not to affect code after the main `let' we need to create a new scope,
24 ;; which is what the surrounding `let' is for.
25 ;; FIXME: (let () ...) currently doesn't actually create a new scope,
26 ;; which is why we use (let (_) ...).
27 `(let (_)
28 ,@(mapcar (lambda (binder)
29 `(defvar ,(if (consp binder) (car binder) binder)))
30 binders)
31 (let ,binders ,@body))))
32
16(provide 'compat) 33(provide 'compat)
17;;; compat.el ends here 34;;; compat.el ends here