From 3cfbfaa4817d16d03e4d7447960c50c42d206295 Mon Sep 17 00:00:00 2001 From: jao Date: Fri, 11 Mar 2022 23:00:30 +0000 Subject: gnus notmuch tags: toggle on delete, append on move --- lib/net/jao-notmuch-gnus.el | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lib/net') diff --git a/lib/net/jao-notmuch-gnus.el b/lib/net/jao-notmuch-gnus.el index b505ced..b6fafcd 100644 --- a/lib/net/jao-notmuch-gnus.el +++ b/lib/net/jao-notmuch-gnus.el @@ -87,11 +87,14 @@ (when (string-match ".+:\\(.+\\)" group) (split-string (match-string 1 group) "\\."))) -(defun jao-notmuch-gnus-tag-on-move (_operation headers from to _d) +(defun jao-notmuch-gnus-tag-on-move (op 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)))) + (if (eq op 'delete) + (let ((cur (seq-difference (jao-notmuch-gnus--group-tags from) to-tags))) + (jao-notmuch-gnus-toggle-tags (append cur to-tags) id cur)) + (notmuch-tag (concat "id:" id) + (mapcar (lambda (x) (concat "+" x)) to-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) -- cgit v1.2.3