diff options
| author | Kyle Meyer <kyle@kyleam.com> | 2021-05-08 09:11:12 -0300 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2021-05-15 08:34:28 -0300 |
| commit | 319dcfb50e5bc929719167afa353e19632ea55f3 (patch) | |
| tree | 81e4a7efbfa025cfab2ad77e5fe10c0bfc737eff /emacs/notmuch-compat.el | |
| parent | a663783343cb992d132ecc18e4e4d4e37bbf12e9 (diff) | |
emacs: restore tag-changes and query bindings for tag hooks
notmuch-before-tag-hook and notmuch-after-tag-hook are supposed to
have access to two dynamic variables, tag-changes and query, but these
were lost with the switch to lexical binding in fc4cda07 (emacs: use
lexical-bindings in all libraries, 2021-01-13).
Add a variant of Emacs's dlet (not available until Emacs 28) and use
it in notmuch-tag to expose tag-changes and query to the hooks.
Diffstat (limited to 'emacs/notmuch-compat.el')
| -rw-r--r-- | emacs/notmuch-compat.el | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/emacs/notmuch-compat.el b/emacs/notmuch-compat.el index ad134dfe..179bf59c 100644 --- a/emacs/notmuch-compat.el +++ b/emacs/notmuch-compat.el @@ -41,6 +41,18 @@ (unless (fboundp 'message--fold-long-headers) (add-hook 'message-header-hook 'notmuch-message--fold-long-headers)) +;; `dlet' isn't available until Emacs 28.1. Below is a copy, with the +;; addition of `with-no-warnings'. +(defmacro notmuch-dlet (binders &rest body) + "Like `let*' but using dynamic scoping." + (declare (indent 1) (debug let)) + `(let (_) + (with-no-warnings ; Quiet "lacks a prefix" warning. + ,@(mapcar (lambda (binder) + `(defvar ,(if (consp binder) (car binder) binder))) + binders)) + (let* ,binders ,@body))) + (provide 'notmuch-compat) ;;; notmuch-compat.el ends here |
