Re: [PATCH] config: allow custom separators in author lists

2024-07-26 Thread David Bremner
Lars Kotthoff  writes:

> Thanks David, I've attached the modified patch that I think addresses
> all your comments -- I'm still not 100% sure about the whitespace
> though.

tweaked version applied to master.
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH] config: allow custom separators in author lists

2024-07-25 Thread Lars Kotthoff
Thanks David, I've attached the modified patch that I think addresses all your 
comments -- I'm still not 100% sure about the whitespace though.

Thanks,

Lars


On Thu, 25 Jul 2024 17:33:48 +0900, David Bremner  wrote:
> Lars Kotthoff  writes:
> 
> > Sorry, I dropped the ball on this -- here's the patch again with space/tab 
> > inconsistencies fixed. I wasn't entirely sure about this as it's 
> > inconsistent in the existing source, so I tried to make it as consistent as 
> > possible. Cover included again below.
> >
> 
> Hi Lars,
> 
> Thanks for sticking with this, and sorry I did not respond to the first
> thread. There are still one or two minor whitespace issues.  If you have
> "uncrustify" installed, then ./devel/check-notmuch-commit && git diff
> will find the ones I'm thinking of. You can ignore the problems you
> didn't introduce.
> 
> > The attached patch allows to customize the default ", " and "| "
> > separators in author lists. The main rationale for supporting this is
> > that the Python API uses the same functionality to get the list of
> > authors -- if I want to separate them again afterwards, I have to
> > split the returned string, which is error-prone with comma separators
> > (e.g. name in email address is of form Lastname, Firstname).
> 
> Can you add a brief summary of the motivation to the commit message?
> 
> >  test/T030-config.sh |  2 ++
> >  test/T055-path-config.sh|  4 
> >  test/T590-libconfig.sh  | 10 ++
> 
> Thanks for adjusting the existing test suite.
> 
> Can you also add a simple test to check the functionality you
> introduced? Testing the CLI is fine, or if you prefer something in the
> style of test/T590-libconfig.sh
> 
From 60aab0c8a9a8164abb32ea306b7fd894a18a2477 Mon Sep 17 00:00:00 2001
From: Lars Kotthoff 
Date: Fri, 22 Dec 2023 14:06:34 -0700
Subject: [PATCH] config: allow custom separators in author lists to allow to distinguish between commas separating authors and separating first and last names

---
 NEWS| 11 +++
 doc/man1/notmuch-config.rst | 13 +
 lib/config.cc   |  8 
 lib/notmuch.h   |  2 ++
 lib/thread.cc   | 19 ++-
 test/T030-config.sh |  2 ++
 test/T055-path-config.sh|  4 
 test/T590-libconfig.sh  | 10 ++
 8 files changed, 64 insertions(+), 5 deletions(-)

diff --git a/NEWS b/NEWS
index 315f4136..b306d095 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,14 @@
+Notmuch 0.39 (UNRELEASED)
+=
+
+General
+---
+
+Allow to customize the separator between individual and matched and non-matched
+authors when showing threads. See `search.authors_separator` and
+`search.authors_matched_separator` in notmuch-config(1).
+
+
 Notmuch 0.38.2 (2023-12-01)
 ===
 
diff --git a/doc/man1/notmuch-config.rst b/doc/man1/notmuch-config.rst
index bd34afa4..5106655f 100644
--- a/doc/man1/notmuch-config.rst
+++ b/doc/man1/notmuch-config.rst
@@ -273,6 +273,19 @@ paths are presumed relative to `$HOME` for items in section
 Default: empty list. Note that :any:`notmuch-setup(1)` puts
 ``deleted;spam`` here when creating new configuration file.
 
+.. nmconfig:: search.authors_separator
+
+The string to separate authors when showing a thread.
+
+Default: ,
+
+.. nmconfig:: search.authors_matched_separator
+
+The string to separate matched from non-matched authors when showing a
+thread.
+
+Default: |
+
 .. nmconfig:: show.extra_headers
 
 By default :any:`notmuch-show(1)` includes the following headers
diff --git a/lib/config.cc b/lib/config.cc
index 6cd15fab..a3102dce 100644
--- a/lib/config.cc
+++ b/lib/config.cc
@@ -608,6 +608,10 @@ _notmuch_config_key_to_string (notmuch_config_key_t key)
 	return "database.autocommit";
 case NOTMUCH_CONFIG_EXTRA_HEADERS:
 	return "show.extra_headers";
+case NOTMUCH_CONFIG_AUTHORS_SEPARATOR:
+	return "search.authors_separator";
+case NOTMUCH_CONFIG_AUTHORS_MATCHED_SEPARATOR:
+	return "search.authors_matched_separator";
 case NOTMUCH_CONFIG_INDEX_AS_TEXT:
 	return "index.as_text";
 default:
@@ -658,6 +662,10 @@ _notmuch_config_default (notmuch_database_t *notmuch, notmuch_config_key_t key)
 	return "";
 case NOTMUCH_CONFIG_AUTOCOMMIT:
 	return "8000";
+case NOTMUCH_CONFIG_AUTHORS_SEPARATOR:
+	return ", ";
+case NOTMUCH_CONFIG_AUTHORS_MATCHED_SEPARATOR:
+	return "| ";
 case NOTMUCH_CONFIG_EXTRA_HEADERS:
 case NOTMUCH_CONFIG_HOOK_DIR:
 case NOTMUCH_CONFIG_BACKUP_DIR:
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 4e2b0fa4..937fa24e 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -2565,6 +2565,8 @@ typedef enum {
 NOTMUCH_CONFIG_AUTOCOMMIT,
 NOTMUCH_CONFIG_EXTRA_HEADERS,
 NOTMUCH_CONFIG_INDEX_AS_TEXT,
+NOTMUCH_CONFIG_AUTHORS_SEPARATOR,
+NOTMUCH_CONFIG_AUTHORS_MATCHED_SEPARATOR,
 NOTMUCH_CONFIG_LAST
 } notmuch_config_key_t;
 
diff --git 

Re: [PATCH] config: allow custom separators in author lists

2024-07-25 Thread David Bremner
Lars Kotthoff  writes:

> Sorry, I dropped the ball on this -- here's the patch again with space/tab 
> inconsistencies fixed. I wasn't entirely sure about this as it's inconsistent 
> in the existing source, so I tried to make it as consistent as possible. 
> Cover included again below.
>

Hi Lars,

Thanks for sticking with this, and sorry I did not respond to the first
thread. There are still one or two minor whitespace issues.  If you have
"uncrustify" installed, then ./devel/check-notmuch-commit && git diff
will find the ones I'm thinking of. You can ignore the problems you
didn't introduce.

> The attached patch allows to customize the default ", " and "| "
> separators in author lists. The main rationale for supporting this is
> that the Python API uses the same functionality to get the list of
> authors -- if I want to separate them again afterwards, I have to
> split the returned string, which is error-prone with comma separators
> (e.g. name in email address is of form Lastname, Firstname).

Can you add a brief summary of the motivation to the commit message?

>  test/T030-config.sh |  2 ++
>  test/T055-path-config.sh|  4 
>  test/T590-libconfig.sh  | 10 ++

Thanks for adjusting the existing test suite.

Can you also add a simple test to check the functionality you
introduced? Testing the CLI is fine, or if you prefer something in the
style of test/T590-libconfig.sh
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH] config: allow custom separators in author lists

2024-02-16 Thread Tomi Ollila
On Fri, Dec 22 2023, Lars Kotthoff wrote:

> The attached patch allows to customize the default ", " and "| "
> separators in author lists. The main rationale for supporting this is
> that the Python API uses the same functionality to get the list of
> authors -- if I want to separate them again afterwards, I have to split
> the returned string, which is error-prone with comma separators
> (e.g. name in email address is of form Lastname, Firstname).

>
> Cheers,
>
> Lars
> From 60aab0c8a9a8164abb32ea306b7fd894a18a2477 Mon Sep 17 00:00:00 2001
> From: Lars Kotthoff 
> Date: Fri, 22 Dec 2023 14:06:34 -0700
> Subject: [PATCH] config: allow custom separators in author lists
>
> ---
>  NEWS| 11 +++
>  doc/man1/notmuch-config.rst | 13 +
>  lib/config.cc   |  8 
>  lib/notmuch.h   |  2 ++
>  lib/thread.cc   | 19 ++-
>  test/T030-config.sh |  2 ++
>  test/T055-path-config.sh|  4 
>  test/T590-libconfig.sh  | 10 ++
>  8 files changed, 64 insertions(+), 5 deletions(-)
>
> diff --git a/NEWS b/NEWS
> index 315f4136..b306d095 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -1,3 +1,14 @@
> +Notmuch 0.38.3 (?)
> +=

The format for yet-unreleased news block here would be:

Notmuch 0.39 (UNRELEASED)
=

If there is going to be 0.38.3 with this included, then,
at that time the version string is adjusted accordingly.

> +
> +General
> +---
> +
> +Allow to customize the separator between individual and matched and 
> non-matched
> +authors when showing threads. See `search.authors_separator` and
> +`search.authors_matched_separator` in notmuch-config(1).
> +
> +
>  Notmuch 0.38.2 (2023-12-01)
>  ===
>  

// stuff deleted //

> diff --git a/lib/config.cc b/lib/config.cc
> index 6cd15fab..a3102dce 100644
> --- a/lib/config.cc
> +++ b/lib/config.cc
> @@ -608,6 +608,10 @@ _notmuch_config_key_to_string (notmuch_config_key_t key)
>   return "database.autocommit";
>  case NOTMUCH_CONFIG_EXTRA_HEADERS:
>   return "show.extra_headers";
> +case NOTMUCH_CONFIG_AUTHORS_SEPARATOR:
> + return "search.authors_separator";
> +case NOTMUCH_CONFIG_AUTHORS_MATCHED_SEPARATOR:
> + return "search.authors_matched_separator";
>  case NOTMUCH_CONFIG_INDEX_AS_TEXT:
>   return "index.as_text";
>  default:
> @@ -658,6 +662,10 @@ _notmuch_config_default (notmuch_database_t *notmuch, 
> notmuch_config_key_t key)
>   return "";
>  case NOTMUCH_CONFIG_AUTOCOMMIT:
>   return "8000";
> +case NOTMUCH_CONFIG_AUTHORS_SEPARATOR:
> +return ", ";
> +case NOTMUCH_CONFIG_AUTHORS_MATCHED_SEPARATOR:
> +return "| ";

Spaces instead of tabs above ?

>  case NOTMUCH_CONFIG_EXTRA_HEADERS:
>  case NOTMUCH_CONFIG_HOOK_DIR:
>  case NOTMUCH_CONFIG_BACKUP_DIR:
> diff --git a/lib/notmuch.h b/lib/notmuch.h

Just noticed the above and that there are more tabs/spaces inconsistencies,
-- and using 4 (instead of 8) in tab width is another thing that makes
the code to be inconsistently laid out.

Otherwise the code looks pretty straightforward, we'll see...

Tomi
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH] config: allow custom separators in author lists

2024-02-15 Thread Lars Kotthoff
Any chance of this being included?

Thanks,

Lars


On Fri, 22 Dec 2023 14:15:32 -0700, Lars Kotthoff  wrote:
> The attached patch allows to customize the default ", " and "| " separators 
> in author lists. The main rationale for supporting this is that the Python 
> API uses the same functionality to get the list of authors -- if I want to 
> separate them again afterwards, I have to split the returned string, which is 
> error-prone with comma separators (e.g. name in email address is of form 
> Lastname, Firstname).
> 
> Cheers,
> 
> Lars
> ___
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-le...@notmuchmail.org
> 
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH] config: allow custom separators in author lists

2023-12-22 Thread Lars Kotthoff
Thanks for your suggestion! This doesn't work unfortunately because the author 
string doesn't contain the email addresses, i.e. no @ symbols (unless somebody 
includes that in their name).

Cheers,

Lars


On Fri, 22 Dec 2023 23:24:37 +0100, Sandra Snan 
 wrote:
> Curses, flowed again! I'm just gonna attach the file
> 
> ___
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-le...@notmuchmail.org
> 
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH] config: allow custom separators in author lists

2023-12-22 Thread Sandra Snan

Curses, flowed again! I'm just gonna attach the file

email_list = "Diaz, Marco , s...@mewni.com, Marco Diaz , s...@mewni.com"
addresses = []
current_address = ""

for char in email_list:
if char == ',' and '@' in current_address:
addresses.append(current_address.strip())
current_address = ""
else:
current_address += char

addresses.append(current_address.strip())  # Adding the last address

print(addresses)
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH] config: allow custom separators in author lists

2023-12-22 Thread Sandra Snan
Lars Kotthoff  writes: 
Python […] I have to split the returned string, which is 
error-prone with comma separators (e.g. name in email address is 
of form Lastname, Firstname). 


email_list = "Diaz, Marco , s...@mewni.com, Marco 
Diaz , s...@mewni.com" addresses = [] 
current_address = ""  for char in email_list: 
   if char == ',' and '@' in current_address: 
   addresses.append(current_address.strip()) current_address 
   = "" 
   else: 
   current_address += char


addresses.append(current_address.strip())  # Adding the last 
address  print(addresses)


## prints ['Diaz, Marco ', 's...@mewni.com', 'Marco 
  Diaz ', 's...@mewni.com']


## (Trying again since use-hard-newlines borked the flow)
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH] config: allow custom separators in author lists

2023-12-22 Thread Sandra Snan

Lars Kotthoff  writes:
Python […] I have to split the returned string, which is 
error-prone with comma separators (e.g. name in email address is 
of form Lastname, Firstname). 


email_list = "Diaz, Marco , s...@mewni.com, Marco 
Diaz , s...@mewni.com" addresses = [] 
current_address = ""  for char in email_list: 
   if char == ',' and '@' in current_address: 
   addresses.append(current_address.strip()) current_address 
   = "" 
   else: 
   current_address += char 

addresses.append(current_address.strip())  # Adding the last 
address  print(addresses) 

## prints ['Diaz, Marco ', 's...@mewni.com', 'Marco 
  Diaz ', 's...@mewni.com'] 


___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org