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

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

Date: Fri, 16 Feb 2024 12:28:55 +0200

To: Lars Kotthoff, notmuch@notmuchmail.org

Cc:

From: 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 <lars@larsko.org>
> 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-leave@notmuchmail.org

Thread: