From fe1df4248113ff5f464c0bcc6891e5cdf0d99df2 Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Fri, 30 Mar 2018 14:13:39 +0100 Subject: [PATCH] refactor: mailcap config Precedence: environment, config file, code --- init.c | 16 +++++----------- init.h | 6 +++++- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/init.c b/init.c index 6ce49378c..e5d6b2246 100644 --- 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 263f0f188..2ae357d50 100644 --- 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 }, /* -- 2.40.0