summary refs log tree commit diff stats
path: root/lisp
diff options
context:
space:
mode:
authorCase Duckworth2022-04-12 13:16:49 -0500
committerCase Duckworth2022-04-12 13:16:49 -0500
commit6f1f0de1c1a843b75083d827109dbe489f50d3b6 (patch)
tree49a10848bf4c3ee384729b397a45738cf5efa71c /lisp
parentAdd +dired-goto-file (diff)
downloademacs-6f1f0de1c1a843b75083d827109dbe489f50d3b6.tar.gz
emacs-6f1f0de1c1a843b75083d827109dbe489f50d3b6.zip
Add dlet to compat.el
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