summaryrefslogtreecommitdiffhomepage
path: root/lib/net/jao-notmuch-gnus.el
diff options
context:
space:
mode:
Diffstat (limited to 'lib/net/jao-notmuch-gnus.el')
-rw-r--r--lib/net/jao-notmuch-gnus.el16
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)