aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLars Kotthoff <larsko@uwyo.edu>2023-12-22 14:06:34 -0700
committerDavid Bremner <david@tethera.net>2024-07-26 15:59:11 +0900
commitd34720e7b35da771d9a06ee8dbdc158680684e99 (patch)
treedbee65525861e729f77042b84f678c9b9ef81e2e /lib
parent199e2de224440833d07665e4cf779a88f3d52863 (diff)
config: allow custom separators in author lists
Allow distinguishing between commas separating authors and separating first and last names. Amended by db: reformat NEWS entry and commit message. Tweaked whitespace in lib/thread.cc.
Diffstat (limited to 'lib')
-rw-r--r--lib/config.cc8
-rw-r--r--lib/notmuch.h2
-rw-r--r--lib/thread.cc19
3 files changed, 24 insertions, 5 deletions
diff --git a/lib/config.cc b/lib/config.cc
index 6cd15fab..acb397ec 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 a/lib/thread.cc b/lib/thread.cc
index 60e9a666..168a9e8b 100644
--- a/lib/thread.cc
+++ b/lib/thread.cc
@@ -122,21 +122,28 @@ _thread_add_matched_author (notmuch_thread_t *thread,
/* Construct an authors string from matched_authors_array and
* authors_array. The string contains matched authors first, then
- * non-matched authors (with the two groups separated by '|'). Within
- * each group, authors are listed in date order. */
+ * non-matched authors (with the two groups separated by '|' or the custom
+ * separator defined in the configuration). Within each group, authors are
+ * listed in date order and separated by ',' or the custom separator defined in
+ * the configuration. */
static void
_resolve_thread_authors_string (notmuch_thread_t *thread)
{
unsigned int i;
char *author;
int first_non_matched_author = 1;
+ const char *authors_sep = notmuch_config_get (thread->notmuch,
+ NOTMUCH_CONFIG_AUTHORS_SEPARATOR);
+ const char *authors_matched_sep = notmuch_config_get (thread->notmuch,
+ NOTMUCH_CONFIG_AUTHORS_MATCHED_SEPARATOR);
/* First, list all matched authors in date order. */
for (i = 0; i < thread->matched_authors_array->len; i++) {
author = (char *) g_ptr_array_index (thread->matched_authors_array, i);
if (thread->authors)
- thread->authors = talloc_asprintf (thread, "%s, %s",
+ thread->authors = talloc_asprintf (thread, "%s%s%s",
thread->authors,
+ authors_sep,
author);
else
thread->authors = author;
@@ -149,12 +156,14 @@ _resolve_thread_authors_string (notmuch_thread_t *thread)
author, NULL, NULL))
continue;
if (first_non_matched_author) {
- thread->authors = talloc_asprintf (thread, "%s| %s",
+ thread->authors = talloc_asprintf (thread, "%s%s%s",
thread->authors,
+ authors_matched_sep,
author);
} else {
- thread->authors = talloc_asprintf (thread, "%s, %s",
+ thread->authors = talloc_asprintf (thread, "%s%s%s",
thread->authors,
+ authors_sep,
author);
}