mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-21 10:28:09 +01:00
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.
This commit is contained in:
parent
199e2de224
commit
d34720e7b3
9 changed files with 90 additions and 5 deletions
11
NEWS
11
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.3 (2024-03-09)
|
||||
===========================
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,8 @@ index.as_text=
|
|||
maildir.synchronize_flags=true
|
||||
new.ignore=
|
||||
new.tags=unread;inbox
|
||||
search.authors_matched_separator=|
|
||||
search.authors_separator=,
|
||||
search.exclude_tags=
|
||||
user.name=Notmuch Test Suite
|
||||
user.other_email=test_suite_other@notmuchmail.org;test_suite@otherdomain.org
|
||||
|
|
|
@ -303,6 +303,8 @@ index.as_text=
|
|||
maildir.synchronize_flags=true
|
||||
new.ignore=
|
||||
new.tags=unread;inbox
|
||||
search.authors_matched_separator=|
|
||||
search.authors_separator=,
|
||||
search.exclude_tags=
|
||||
user.name=Notmuch Test Suite
|
||||
user.other_email=test_suite_other@notmuchmail.org;test_suite@otherdomain.org
|
||||
|
@ -325,6 +327,8 @@ database.mail_root
|
|||
database.path
|
||||
maildir.synchronize_flags
|
||||
new.tags
|
||||
search.authors_matched_separator
|
||||
search.authors_separator
|
||||
user.name
|
||||
user.other_email
|
||||
user.primary_email
|
||||
|
|
26
test/T206-author-separator.sh
Executable file
26
test/T206-author-separator.sh
Executable file
|
@ -0,0 +1,26 @@
|
|||
#!/usr/bin/env bash
|
||||
test_description="custom separator for authors"
|
||||
. $(dirname "$0")/test-lib.sh || exit 1
|
||||
|
||||
test_begin_subtest "Adding parent message"
|
||||
generate_message [body]=findme [id]=new-parent-id [subject]=author-reorder-threadtest '[from]="User <user@example.com>"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
|
||||
output=$(NOTMUCH_NEW)
|
||||
test_expect_equal "$output" "Added 1 new message to the database."
|
||||
|
||||
test_begin_subtest "Adding initial child message"
|
||||
generate_message [body]=findme "[in-reply-to]=\<new-parent-id\>" [subject]=author-reorder-threadtest '[from]="last name, first name <user1@example.com>"' '[date]="Sat, 01 Jan 2000 12:01:00 -0000"'
|
||||
output=$(NOTMUCH_NEW)
|
||||
test_expect_equal "$output" "Added 1 new message to the database."
|
||||
|
||||
test_begin_subtest "Adding second child message"
|
||||
generate_message [body]=findme "[in-reply-to]=\<new-parent-id\>" [subject]=author-reorder-threadtest '[from]="first last <user2@example.com>"' '[date]="Sat, 01 Jan 2000 12:02:00 -0000"'
|
||||
output=$(NOTMUCH_NEW)
|
||||
test_expect_equal "$output" "Added 1 new message to the database."
|
||||
|
||||
test_begin_subtest "Custom separarator is used"
|
||||
notmuch config set search.authors_matched_separator "#"
|
||||
notmuch config set search.authors_separator ";"
|
||||
output=$(notmuch search from:user | notmuch_search_sanitize)
|
||||
test_expect_equal "$output" "thread:XXX 2000-01-01 [1/3] User#last name, first name;first last; author-reorder-threadtest (inbox unread)"
|
||||
|
||||
test_done
|
|
@ -441,6 +441,8 @@ cat <<'EOF' >EXPECTED
|
|||
11: '8000'
|
||||
12: 'NULL'
|
||||
13: ''
|
||||
14: ', '
|
||||
15: '| '
|
||||
== stderr ==
|
||||
EOF
|
||||
unset MAILDIR
|
||||
|
@ -725,6 +727,8 @@ test_expect_equal_file EXPECTED OUTPUT
|
|||
|
||||
test_begin_subtest "list by keys (ndlc)"
|
||||
notmuch config set search.exclude_tags "foo;bar;fub"
|
||||
notmuch config set search.authors_matched_separator "| "
|
||||
notmuch config set search.authors_separator ", "
|
||||
notmuch config set new.ignore "sekrit_junk"
|
||||
notmuch config set index.as_text "text/"
|
||||
cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} %NULL% %NULL%
|
||||
|
@ -754,6 +758,8 @@ cat <<'EOF' >EXPECTED
|
|||
11: '8000'
|
||||
12: 'NULL'
|
||||
13: 'text/'
|
||||
14: ', '
|
||||
15: '| '
|
||||
== stderr ==
|
||||
EOF
|
||||
test_expect_equal_file EXPECTED OUTPUT
|
||||
|
@ -789,6 +795,8 @@ cat <<'EOF' >EXPECTED
|
|||
11: '8000'
|
||||
12: 'NULL'
|
||||
13: ''
|
||||
14: ', '
|
||||
15: '| '
|
||||
== stderr ==
|
||||
EOF
|
||||
test_expect_equal_file EXPECTED OUTPUT.clean
|
||||
|
@ -865,6 +873,8 @@ key with spaces value, with, spaces!
|
|||
maildir.synchronize_flags true
|
||||
new.ignore sekrit_junk
|
||||
new.tags unread;inbox
|
||||
search.authors_matched_separator |
|
||||
search.authors_separator ,
|
||||
search.exclude_tags foo;bar;fub
|
||||
show.extra_headers (null)
|
||||
test.key1 testvalue1
|
||||
|
|
Loading…
Reference in a new issue