diff options
author | jao <jao@gnu.org> | 2022-03-11 21:44:18 +0000 |
---|---|---|
committer | jao <jao@gnu.org> | 2022-03-11 21:44:18 +0000 |
commit | f4197d5356b401e941dd0471a7b62fc026af4d67 (patch) | |
tree | 6792c4c84f531bcc343e54ecefc9bb95ed775482 /lib/net | |
parent | 30d591f40939dfa2fa3a3b5aee9e666b7686b87b (diff) | |
download | elibs-f4197d5356b401e941dd0471a7b62fc026af4d67.tar.gz elibs-f4197d5356b401e941dd0471a7b62fc026af4d67.tar.bz2 |
toggling automatic notmuch tagging on gnus' moves
Diffstat (limited to 'lib/net')
-rw-r--r-- | lib/net/jao-notmuch-gnus.el | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/lib/net/jao-notmuch-gnus.el b/lib/net/jao-notmuch-gnus.el index 4bc86c4..b505ced 100644 --- a/lib/net/jao-notmuch-gnus.el +++ b/lib/net/jao-notmuch-gnus.el @@ -66,10 +66,10 @@ (when-let (id (jao-notmuch-gnus-message-id)) (message "%s" (string-join (jao-notmuch-gnus-message-tags id) " ")))) -(defun jao-notmuch-gnus-toggle-tags (tags &optional id) +(defun jao-notmuch-gnus-toggle-tags (tags &optional id current) "Toggle the given TAGS list for the current Gnus message." (let* ((id (or id (jao-notmuch-gnus-message-id))) - (current (jao-notmuch-gnus-message-tags id)) + (current (or current (jao-notmuch-gnus-message-tags id))) (tags (mapcar (lambda (x) (concat (if (member x current) "-" "+") x)) tags))) @@ -87,13 +87,11 @@ (when (string-match ".+:\\(.+\\)" group) (split-string (match-string 1 group) "\\."))) -(defun jao-notmuch-gnus-tag-on-move (operation headers from to d) - (when-let (id (and to (jao-notmuch-gnus--notmuch-id (mail-header-id headers)))) - (when-let* ((to-tags (jao-notmuch-gnus--group-tags to)) - (from-tags (jao-notmuch-gnus--group-tags from)) - (new-tags (seq-difference to-tags from-tags)) - (new-tags (mapcar (lambda (x) (concat "+" x)) new-tags))) - (notmuch-tag (concat "id:" id) new-tags)))) +(defun jao-notmuch-gnus-tag-on-move (_operation headers from to _d) + (when-let* ((to-tags (when to (jao-notmuch-gnus--group-tags to))) + (id (jao-notmuch-gnus--notmuch-id (mail-header-id headers)))) + (let ((from-tags (seq-difference (jao-notmuch-gnus--group-tags from) to-tags))) + (jao-notmuch-gnus-toggle-tags (append from-tags to-tags) id from-tags)))) (add-hook 'gnus-summary-article-move-hook #'jao-notmuch-gnus-tag-on-move) (add-hook 'gnus-summary-article-expire-hook #'jao-notmuch-gnus-tag-on-move) |