diff options
author | Case Duckworth | 2022-04-12 13:16:49 -0500 |
---|---|---|
committer | Case Duckworth | 2022-04-12 13:16:49 -0500 |
commit | 6f1f0de1c1a843b75083d827109dbe489f50d3b6 (patch) | |
tree | 49a10848bf4c3ee384729b397a45738cf5efa71c | |
parent | Add +dired-goto-file (diff) | |
download | emacs-6f1f0de1c1a843b75083d827109dbe489f50d3b6.tar.gz emacs-6f1f0de1c1a843b75083d827109dbe489f50d3b6.zip |
Add dlet to compat.el
-rw-r--r-- | lisp/compat.el | 17 |
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 |