From: Richard Russon Date: Fri, 30 Mar 2018 15:55:12 +0000 (+0100) Subject: refactor: editor, visual config X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=70a9826d24d1f48258c9bb816f343b609a38a9cb;p=neomutt refactor: editor, visual config Precedence: environment, config, code --- diff --git a/init.c b/init.c index 5c10dbf1e..fac1ac7b0 100644 --- a/init.c +++ b/init.c @@ -3760,16 +3760,6 @@ int mutt_init(int skip_sys_rc, struct ListHead *commands) SpoolFile = mutt_str_strdup(buffer); } - p = mutt_str_getenv("VISUAL"); - if (!p) - { - p = mutt_str_getenv("EDITOR"); - if (!p) - p = "vi"; - } - Editor = mutt_str_strdup(p); - Visual = mutt_str_strdup(p); - p = mutt_str_getenv("REPLYTO"); if (p) { @@ -3939,6 +3929,16 @@ int mutt_init(int skip_sys_rc, struct ListHead *commands) if (env_tmp) mutt_str_replace(&Tmpdir, env_tmp); + /* "$visual", "$editor" precedence: environment, config file, code */ + const char *env_ed = mutt_str_getenv("VISUAL"); + if (!env_ed) + env_ed = mutt_str_getenv("EDITOR"); + if (env_ed) + { + mutt_str_replace(&Editor, env_ed); + mutt_str_replace(&Visual, env_ed); + } + if (need_pause && !OPT_NO_CURSES) { log_queue_flush(log_disp_terminal); diff --git a/init.h b/init.h index 76bd4cfed..07bfee1cf 100644 --- a/init.h +++ b/init.h @@ -813,7 +813,7 @@ struct Option MuttVars[] = { ** \fBNote\fP that changes made to the References: and Date: headers are ** ignored for interoperability reasons. */ - { "editor", DT_PATH, R_NONE, &Editor, 0 }, + { "editor", DT_PATH, R_NONE, &Editor, IP "vi" }, /* ** .pp ** This variable specifies which editor is used by NeoMutt. @@ -4310,11 +4310,13 @@ struct Option MuttVars[] = { ** virtual-mailboxes) as a spool file. */ #endif - { "visual", DT_PATH, R_NONE, &Visual, 0 }, + { "visual", DT_PATH, R_NONE, &Visual, IP "vi" }, /* ** .pp ** Specifies the visual editor to invoke when the ``\fC~v\fP'' command is ** given in the built-in editor. + ** .pp + ** $$visual is overridden by the environment variable \fC$$$VISUAL\fP. */ { "wait_key", DT_BOOL, R_NONE, &WaitKey, 1 }, /*