From 6735894ca5ce48957b567d123819ee909edcb447 Mon Sep 17 00:00:00 2001 From: Austin Ray Date: Thu, 9 May 2019 20:05:22 -0400 Subject: [PATCH] feat: use mailbox description for spoolfile 'spoolfile' is limited to mailboxes paths so if one wants to use a 'named-mailboxes' or 'virtual-mailboxes' as the spoolfile, its path must be duplicated in the 'spoolfile' assignment. 'virtual-mailboxes' has a helper variable, 'virtual_spoolfile', for selecting the first 'virtual-mailboxes' entry as the spoolfile. This commit allows one to use a mailbox description for the 'spoolfile, which removes the need to duplicate a 'named-mailboxes' or 'virtual-mailboxes' path and makes 'virtual_spoolfile' defunct. The configuration syntax is now more consistent. It is important to note that mailbox descriptions are preferred to paths. To reflect the change, documentation was updated: - Add note to 'spoolfile' about using a string to specify a 'named-mailboxes' or 'virtual-mailboxes' description. - Add a note to the 'virtual_spoolfile' documentation saying that it is no longer necessary since 'spoolfile' supports descriptions now. --- doc/manual.xml.head | 16 +++++++++++++++- init.h | 6 +++++- main.c | 9 ++++++++- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/doc/manual.xml.head b/doc/manual.xml.head index 49f5caf1e..3896798de 100644 --- a/doc/manual.xml.head +++ b/doc/manual.xml.head @@ -15272,12 +15272,13 @@ virtual-mailboxes "My INBOX" "notmuch://?query=tag:inbox" Notmuch Variables - + Name Type Default + Note @@ -15285,51 +15286,64 @@ virtual-mailboxes "My INBOX" "notmuch://?query=tag:inbox" nm_db_limitnumber0 + nm_default_uri string (empty) + nm_exclude_tags string (empty) + nm_open_timeout number 5 + nm_query_type string messages + nm_record boolean no + nm_record_tags string (empty) + nm_unread_tag string unread + vfolder_format string %6n(%6N) %f + virtual_spoolfile boolean no + + Unnecessary since $spoolfile + supports mailbox descriptions. + diff --git a/init.h b/init.h index 7cc97cd0f..5c5a45e10 100644 --- a/init.h +++ b/init.h @@ -4205,7 +4205,8 @@ struct ConfigDef MuttVars[] = { /* ** .pp ** If your spool mailbox is in a non-default place where NeoMutt can't find - ** it, you can specify its location with this variable. + ** it, you can specify its location with this variable. The description from + ** "named-mailboxes" or "virtual-mailboxes" may be used for the spoolfile. ** .pp ** If not specified, then the environment variables \fC$$$MAIL\fP and ** \fC$$$MAILDIR\fP will be checked. @@ -4684,6 +4685,9 @@ struct ConfigDef MuttVars[] = { ** .pp ** When \fIset\fP, NeoMutt will use the first defined virtual mailbox (see ** virtual-mailboxes) as a spool file. + ** + ** This command is now unnecessary. $$spoolfile has been extended to support + ** mailbox descriptions as a value. */ #endif { "visual", DT_COMMAND, R_NONE, &C_Visual, IP "vi" }, diff --git a/main.c b/main.c index a82d9bcf1..64244ca7c 100644 --- a/main.c +++ b/main.c @@ -1168,7 +1168,14 @@ int main(int argc, char *argv[], char *envp[]) if (mutt_buffer_len(folder) == 0) { if (C_Spoolfile) - mutt_buffer_strcpy(folder, C_Spoolfile); + { + // Check if C_Spoolfile corresponds a mailboxes' description. + struct Mailbox *desc_m = mutt_find_mailbox_desc(C_Spoolfile); + if (desc_m) + mutt_buffer_strcpy(folder, desc_m->realpath); + else + mutt_buffer_strcpy(folder, C_Spoolfile); + } else if (C_Folder) mutt_buffer_strcpy(folder, C_Folder); /* else no folder */ -- 2.49.0