unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Jonas Bernoulli <jonas@bernoul.li>
To: David Bremner <david@tethera.net>
Subject: [PATCH] emacs: notmuch-fcc-header-setup: fix regression
Date: Tue,  3 Aug 2021 00:10:08 +0200	[thread overview]
Message-ID: <20210802221008.20978-1-jonas@bernoul.li> (raw)
In-Reply-To: <87czqw1621.fsf@tethera.net>

With [1: 16b2db09] we lost the (undocumented) option to use no Fcc
header only for From addresses matching a regexp.  This brings back
that feature and documents it.

1: 2021-01-15 16b2db0986ce0ed7c420a69d0a98bb41e9ca4bd8
   emacs: various cosmetic improvements
---
 emacs/notmuch-maildir-fcc.el | 29 ++++++++++++++++-------------
 1 file changed, 16 insertions(+), 13 deletions(-)

diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el
index c715532b..7e177bf7 100644
--- a/emacs/notmuch-maildir-fcc.el
+++ b/emacs/notmuch-maildir-fcc.el
@@ -41,16 +41,17 @@ (defcustom notmuch-fcc-dirs "sent"
 - a string: the value of `notmuch-fcc-dirs' is the Fcc header to
   be used.
 
-- a list: the folder is chosen based on the From address of the
-  current message using a list of regular expressions and
-  corresponding folders:
+- an alist: the folder is chosen based on the From address of
+  the current message according to an alist mapping regular
+  expressions to folders or nil:
 
      ((\"Sebastian@SSpaeth.de\" . \"privat\")
       (\"spaetz@sspaeth.de\" . \"OUTBOX.OSS\")
       (\".*\" . \"defaultinbox\"))
 
-  If none of the regular expressions match the From address, no
-  Fcc header will be added.
+  If none of the regular expressions match the From address, or
+  if the cdr of the matching entry is nil, then no Fcc header
+  will be added.
 
 If `notmuch-maildir-use-notmuch-insert' is set (the default) then
 the header should be of the form \"folder +tag1 -tag2\" where
@@ -74,7 +75,8 @@ (defcustom notmuch-fcc-dirs "sent"
 	  (const :tag "No FCC header" nil)
 	  (string :tag "A single folder")
 	  (repeat :tag "A folder based on the From header"
-		  (cons regexp (string :tag "Folder"))))
+		  (cons regexp (choice (const :tag "No FCC header" nil)
+				       (string :tag "Folder")))))
   :require 'notmuch-fcc-initialization
   :group 'notmuch-send)
 
@@ -105,13 +107,14 @@ (defun notmuch-fcc-header-setup ()
 	   ;; Old style - no longer works.
 	   (error "Invalid `notmuch-fcc-dirs' setting (old style)"))
 	  ((listp notmuch-fcc-dirs)
-	   (or (seq-some (let ((from (message-field-value "From")))
-			   (pcase-lambda (`(,regexp . ,folder))
-			     (and (string-match-p regexp from)
-				  folder)))
-			 notmuch-fcc-dirs)
-	       (progn (message "No Fcc header added.")
-		      nil)))
+	   (if-let ((match (seq-some (let ((from (message-field-value "From")))
+				       (pcase-lambda (`(,regexp . ,folder))
+					 (and (string-match-p regexp from)
+					      (cons t folder))))
+				     notmuch-fcc-dirs)))
+               (cdr match)
+             (message "No Fcc header added.")
+	     nil))
 	  (t
 	   (error "Invalid `notmuch-fcc-dirs' setting (neither string nor list)")))))
     (when subdir
-- 
2.31.1

  reply	other threads:[~2021-08-04 14:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-07 15:24 emacs: Use of seq-some breaks 'nil' values in notmuch-fcc-dirs Toke Høiland-Jørgensen
2021-08-02 10:42 ` David Bremner
2021-08-02 22:10   ` Jonas Bernoulli [this message]
2021-09-09  1:51     ` [PATCH] emacs: notmuch-fcc-header-setup: fix regression David Bremner
2021-09-11 14:43 ` emacs: Use of seq-some breaks 'nil' values in notmuch-fcc-dirs David Bremner
2021-09-12 16:42   ` Toke Høiland-Jørgensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210802221008.20978-1-jonas@bernoul.li \
    --to=jonas@bernoul.li \
    --cc=david@tethera.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).