unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* emacs: Use of seq-some breaks 'nil' values in notmuch-fcc-dirs
@ 2021-02-07 15:24 Toke Høiland-Jørgensen
  2021-08-02 10:42 ` David Bremner
  2021-09-11 14:43 ` emacs: Use of seq-some breaks 'nil' values in notmuch-fcc-dirs David Bremner
  0 siblings, 2 replies; 6+ messages in thread
From: Toke Høiland-Jørgensen @ 2021-02-07 15:24 UTC (permalink / raw)
  To: notmuch

Hi

Commit 16b2db0986ce ("emacs: various cosmetic improvements") switched
over notmuch-fcc-header-setup to use 'seq-some' to parse the
notmuch-fcc-dirs variables. However, this seems to have broken the use
of 'nil' values in the list. Specifically, I have notmuch-fcc-dirs set
to something like:

'(("toke@onemail.alias" . "alias1/Sent +sent -unread")
  ("toke@another.alias" . nil)
  (".*" . "Sent +sent -unread"))

and since that update, I end up with "Sent +sent -unread" as the FCC
value for emails I initiate from toke@another.alias.

Any chance this could be fixed?

Thanks,
-Toke

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: emacs: Use of seq-some breaks 'nil' values in notmuch-fcc-dirs
  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   ` [PATCH] emacs: notmuch-fcc-header-setup: fix regression Jonas Bernoulli
  2021-09-11 14:43 ` emacs: Use of seq-some breaks 'nil' values in notmuch-fcc-dirs David Bremner
  1 sibling, 1 reply; 6+ messages in thread
From: David Bremner @ 2021-08-02 10:42 UTC (permalink / raw)
  To: Toke Høiland-Jørgensen; +Cc: Jonas Bernoulli

Toke Høiland-Jørgensen <toke@toke.dk> writes:

> Commit 16b2db0986ce ("emacs: various cosmetic improvements") switched
> over notmuch-fcc-header-setup to use 'seq-some' to parse the
> notmuch-fcc-dirs variables. However, this seems to have broken the use
> of 'nil' values in the list. Specifically, I have notmuch-fcc-dirs set
> to something like:
>
> '(("toke@onemail.alias" . "alias1/Sent +sent -unread")
>   ("toke@another.alias" . nil)
>   (".*" . "Sent +sent -unread"))
>
> and since that update, I end up with "Sent +sent -unread" as the FCC
> value for emails I initiate from toke@another.alias.

On the one hand that behaviour was undocumented. On the other hand, it
does seem like a useful thing to want to do. Hopefully Jonas can more
quickly untangle what happened there than I can.

d

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] emacs: notmuch-fcc-header-setup: fix regression
  2021-08-02 10:42 ` David Bremner
@ 2021-08-02 22:10   ` Jonas Bernoulli
  2021-09-09  1:51     ` David Bremner
  0 siblings, 1 reply; 6+ messages in thread
From: Jonas Bernoulli @ 2021-08-02 22:10 UTC (permalink / raw)
  To: David Bremner

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] emacs: notmuch-fcc-header-setup: fix regression
  2021-08-02 22:10   ` [PATCH] emacs: notmuch-fcc-header-setup: fix regression Jonas Bernoulli
@ 2021-09-09  1:51     ` David Bremner
  0 siblings, 0 replies; 6+ messages in thread
From: David Bremner @ 2021-09-09  1:51 UTC (permalink / raw)
  To: Jonas Bernoulli; +Cc: notmuch

Jonas Bernoulli <jonas@bernoul.li> writes:

> 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

applied to master.

d

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: emacs: Use of seq-some breaks 'nil' values in notmuch-fcc-dirs
  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-09-11 14:43 ` David Bremner
  2021-09-12 16:42   ` Toke Høiland-Jørgensen
  1 sibling, 1 reply; 6+ messages in thread
From: David Bremner @ 2021-09-11 14:43 UTC (permalink / raw)
  To: Toke Høiland-Jørgensen, notmuch

Toke Høiland-Jørgensen <toke@toke.dk> writes:

> Hi
>
> Commit 16b2db0986ce ("emacs: various cosmetic improvements") switched
> over notmuch-fcc-header-setup to use 'seq-some' to parse the
> notmuch-fcc-dirs variables. However, this seems to have broken the use
> of 'nil' values in the list. Specifically, I have notmuch-fcc-dirs set
> to something like:
>
> '(("toke@onemail.alias" . "alias1/Sent +sent -unread")
>   ("toke@another.alias" . nil)
>   (".*" . "Sent +sent -unread"))
>
> and since that update, I end up with "Sent +sent -unread" as the FCC
> value for emails I initiate from toke@another.alias.
>
> Any chance this could be fixed?

This should be fixed in commit b03b0d4e

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: emacs: Use of seq-some breaks 'nil' values in notmuch-fcc-dirs
  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
  0 siblings, 0 replies; 6+ messages in thread
From: Toke Høiland-Jørgensen @ 2021-09-12 16:42 UTC (permalink / raw)
  To: David Bremner, notmuch

David Bremner <david@tethera.net> writes:

> Toke Høiland-Jørgensen <toke@toke.dk> writes:
>
>> Hi
>>
>> Commit 16b2db0986ce ("emacs: various cosmetic improvements") switched
>> over notmuch-fcc-header-setup to use 'seq-some' to parse the
>> notmuch-fcc-dirs variables. However, this seems to have broken the use
>> of 'nil' values in the list. Specifically, I have notmuch-fcc-dirs set
>> to something like:
>>
>> '(("toke@onemail.alias" . "alias1/Sent +sent -unread")
>>   ("toke@another.alias" . nil)
>>   (".*" . "Sent +sent -unread"))
>>
>> and since that update, I end up with "Sent +sent -unread" as the FCC
>> value for emails I initiate from toke@another.alias.
>>
>> Any chance this could be fixed?
>
> This should be fixed in commit b03b0d4e

Indeed it is - thanks! :)

-Toke

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-09-12 22:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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   ` [PATCH] emacs: notmuch-fcc-header-setup: fix regression Jonas Bernoulli
2021-09-09  1:51     ` 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

Code repositories for project(s) associated with this inbox:

	notmuch.git.git (no URL configured)

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 NNTP newsgroup(s).