]> granicus.if.org Git - neomutt/commitdiff
refactor: editor, visual config
authorRichard Russon <rich@flatcap.org>
Fri, 30 Mar 2018 15:55:12 +0000 (16:55 +0100)
committerRichard Russon <rich@flatcap.org>
Tue, 3 Apr 2018 02:38:53 +0000 (03:38 +0100)
Precedence: environment, config, code

init.c
init.h

diff --git a/init.c b/init.c
index 5c10dbf1ed471d91cd48dec3c3d809373fd5bfab..fac1ac7b0568abd2a46332377f0df24aa8e1451c 100644 (file)
--- 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 76bd4cfedbd5920353165131c8f3622121967ef4..07bfee1cf6c98977b2290acc1f67ffe60cf5e0aa 100644 (file)
--- 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 },
   /*