]> granicus.if.org Git - neomutt/commitdiff
refactor: mailcap config
authorRichard Russon <rich@flatcap.org>
Fri, 30 Mar 2018 13:13:39 +0000 (14:13 +0100)
committerRichard Russon <rich@flatcap.org>
Tue, 3 Apr 2018 02:38:52 +0000 (03:38 +0100)
Precedence: environment, config file, code

init.c
init.h

diff --git a/init.c b/init.c
index 6ce49378c2586e5ff593905177f9227eb3811c3b..e5d6b2246bc218a24fedd0368a96a0609c0be35f 100644 (file)
--- a/init.c
+++ b/init.c
@@ -3760,17 +3760,6 @@ int mutt_init(int skip_sys_rc, struct ListHead *commands)
     SpoolFile = mutt_str_strdup(buffer);
   }
 
-  p = mutt_str_getenv("MAILCAPS");
-  if (p)
-    MailcapPath = mutt_str_strdup(p);
-  else
-  {
-    /* Default search path from RFC1524 */
-    MailcapPath = mutt_str_strdup(
-        "~/.mailcap:" PKGDATADIR "/mailcap:" SYSCONFDIR
-        "/mailcap:/etc/mailcap:/usr/etc/mailcap:/usr/local/etc/mailcap");
-  }
-
   Tmpdir = mutt_str_strdup((p = mutt_str_getenv("TMPDIR")) ? p : "/tmp");
 
   p = mutt_str_getenv("VISUAL");
@@ -3942,6 +3931,11 @@ int mutt_init(int skip_sys_rc, struct ListHead *commands)
   if (!get_hostname())
     return 1;
 
+  /* "$mailcap_path" precedence: environment, config file, code */
+  const char *env_mc = mutt_str_getenv("MAILCAPS");
+  if (env_mc)
+    mutt_str_replace(&MailcapPath, env_mc);
+
   if (need_pause && !OPT_NO_CURSES)
   {
     log_queue_flush(log_disp_terminal);
diff --git a/init.h b/init.h
index 263f0f188b2027f529b5859422987e984a429969..2ae357d503fe7e4e344b8d9ddec0dbff683841ee 100644 (file)
--- a/init.h
+++ b/init.h
@@ -1685,12 +1685,16 @@ struct Option MuttVars[] = {
   ** .pp
   ** When $$mail_check_stats is \fIset\fP, this variable configures
   ** how often (in seconds) NeoMutt will update message counts.
+  ** .pp
+  ** The default search path is from RFC1524.
   */
-  { "mailcap_path",     DT_STRING,  R_NONE, &MailcapPath, 0 },
+  { "mailcap_path",     DT_STRING,  R_NONE, &MailcapPath, IP "~/.mailcap:" PKGDATADIR "/mailcap:" SYSCONFDIR "/mailcap:/etc/mailcap:/usr/etc/mailcap:/usr/local/etc/mailcap" },
   /*
   ** .pp
   ** This variable specifies which files to consult when attempting to
   ** display MIME bodies not directly supported by NeoMutt.
+  ** .pp
+  ** $$mailcap_path is overridden by the environment variable \fC$$$MAILCAPS\fP.
   */
   { "mailcap_sanitize", DT_BOOL, R_NONE, &MailcapSanitize, 1 },
   /*