From 2f041bda5cedfdce0a6a8b3599d1f6f779764619 Mon Sep 17 00:00:00 2001
From: jao <jao@gnu.org>
Date: Wed, 25 May 2022 23:22:47 +0100
Subject: jao-notmuch: inheriting original's tags in replies

---
 lib/net/jao-notmuch.el | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/lib/net/jao-notmuch.el b/lib/net/jao-notmuch.el
index bd48e8f..6344eab 100644
--- a/lib/net/jao-notmuch.el
+++ b/lib/net/jao-notmuch.el
@@ -414,6 +414,24 @@
     (jao-notmuch-tree--tag tags nil nil)
     (jao-notmuch-tree--next nil nil t t)))
 
+(defvar jao-notmuch-mua-reply-not-inherited
+  '("attachment" "sent" "new" "unread"))
+
+(defun jao-notmuch--append-to-fcc (suffix)
+  (mapcar (lambda (e)
+            (let ((r (cdr e)))
+              (if (stringp r) (cons (car e) (concat r " " suffix)) e)))
+          notmuch-fcc-dirs))
+
+(defun jao-notmuch-mua-new-reply (fun &rest args)
+  (let* ((tags (seq-difference (notmuch-show-get-tags)
+                               jao-notmuch-mua-reply-not-inherited))
+         (tagstr (mapconcat (lambda (s) (concat "+" s)) tags " "))
+         (notmuch-fcc-dirs (jao-notmuch--append-to-fcc tagstr)))
+    (apply fun args)))
+
+(advice-add 'notmuch-mua-new-reply :around #'jao-notmuch-mua-new-reply)
+
 
 ;;;; Results formatters
 
-- 
cgit v1.2.3