]> granicus.if.org Git - mutt/commitdiff
Fix $editor and $visual. Based on an earlier patch from Edmund
authorMichael Elkins <me@sigpipe.org>
Wed, 24 Jul 2002 08:40:06 +0000 (08:40 +0000)
committerMichael Elkins <me@sigpipe.org>
Wed, 24 Jul 2002 08:40:06 +0000 (08:40 +0000)
Grimley Evans.

attach.c
compose.c
doc/mutt.man
editmsg.c
init.c
init.h

index 5921ddf209d264e0c8a2581c49ce2501baed3af6..da5a3cc6da54eef7e60fed3d06ff3c1a3de5fca5 100644 (file)
--- a/attach.c
+++ b/attach.c
@@ -264,8 +264,7 @@ int mutt_edit_attachment (BODY *a)
   else if (a->type == TYPETEXT)
   {
     /* On text, default to editor */
-    mutt_edit_file ((!Editor || mutt_strcmp ("builtin", Editor) == 0) ? 
-                   NONULL(Visual) : NONULL(Editor), newfile);
+    mutt_edit_file (NONULL (Editor), newfile);
   }
   else
   {
index 96ee5dc165f7458884714d0834e733a82bcd0bfe..3970981e3d85093f8675b9165903529189c15678 100644 (file)
--- a/compose.c
+++ b/compose.c
@@ -706,8 +706,8 @@ int mutt_compose_menu (HEADER *msg,   /* structure for new message */
        if (op == OP_COMPOSE_EDIT_HEADERS ||
            (op == OP_COMPOSE_EDIT_MESSAGE && option (OPTEDITHDRS)))
        {
-         mutt_edit_headers ((!Editor || mutt_strcmp ("builtin", Editor) == 0) ? NONULL(Visual) : NONULL(Editor),
-                            msg->content->filename, msg, fcc, fcclen);
+         mutt_edit_headers (NONULL (Editor), msg->content->filename, msg,
+                            fcc, fcclen);
        }
        else
        {
@@ -1061,8 +1061,7 @@ int mutt_compose_menu (HEADER *msg,   /* structure for new message */
 
       case OP_COMPOSE_EDIT_FILE:
        CHECK_COUNT;
-       mutt_edit_file ((!Editor || mutt_strcmp ("builtin", Editor) == 0) ? NONULL(Visual) : NONULL(Editor),
-                       idx[menu->current]->content->filename);
+       mutt_edit_file (NONULL(Editor), idx[menu->current]->content->filename);
        mutt_update_encoding (idx[menu->current]->content);
        menu->redraw = REDRAW_CURRENT | REDRAW_STATUS;
        break;
index ef7fb038cba9ac033e45c5742007549c0cd4ab5c..4dc8b8bd1a7350ed12bf8c65a1eb45711643c7ca 100644 (file)
@@ -103,7 +103,7 @@ command which contains new mail.
 .SH ENVIRONMENT
 .PP
 .IP "EDITOR"
-Editor to invoke when composing a message.
+Specifies the editor to use if VISUAL is unset.
 .IP "EMAIL"
 The user's e-mail address.
 .IP "HOME"
@@ -126,7 +126,7 @@ Directory in which temporary files are created.
 .IP "REPLYTO"
 Default Reply-To address.
 .IP "VISUAL"
-Editor to invoke when the ~v command is given in the builtin editor.
+Specifies the editor to use when composing messages.
 .SH FILES
 .PP
 .IP "~/.muttrc or ~/.mutt/muttrc"
index 5149bb45f4442eda9cf1b8b77f02b39eb4f7cf9f..bf9d17c40c731e24e037a0d901a54584ed14bb92 100644 (file)
--- a/editmsg.c
+++ b/editmsg.c
@@ -88,8 +88,7 @@ static int edit_one_message (CONTEXT *ctx, HEADER *cur)
   if (stat (tmp, &sb) == 0)
     mtime = sb.st_mtime;
 
-  mutt_edit_file ((!Editor || mutt_strcmp ("builtin", Editor) == 0) ? 
-                 NONULL(Visual) : NONULL(Editor), tmp);
+  mutt_edit_file (NONULL(Editor), tmp);
 
   if ((rc = stat (tmp, &sb)) == -1)
   {
diff --git a/init.c b/init.c
index 6e8f1958f35f8fd2e34c8d4ec24eae1788b25c05..0490b0f5f686b62dd66793bc363547ca23a229cb 100644 (file)
--- a/init.c
+++ b/init.c
@@ -1854,8 +1854,16 @@ void mutt_init (int skip_sys_rc, LIST *commands)
   }
 
   Tempdir = safe_strdup ((p = getenv ("TMPDIR")) ? p : "/tmp");
-  Editor = safe_strdup ((p = getenv ("EDITOR")) ? p : "vi");
-  Visual = safe_strdup ((p = getenv ("VISUAL")) ? p : Editor);
+
+  p = getenv ("VISUAL");
+  if (!p)
+  {
+    p = getenv ("EDITOR");
+    if (!p)
+      p = "vi";
+  }
+  Editor = safe_strdup (p);
+  Visual = safe_strdup (p);
 
   if ((p = getenv ("REPLYTO")) != NULL)
   {
diff --git a/init.h b/init.h
index f202d6012fcaa3e9c4ba9a6c30d80a98957fbe52..7aa0c053a9a241ed3982d8f7b776e07a74080624 100644 (file)
--- a/init.h
+++ b/init.h
@@ -463,8 +463,8 @@ struct option_t MuttVars[] = {
   /*
   ** .pp
   ** This variable specifies which editor is used by mutt.
-  ** It defaults to the value of the EDITOR or VISUAL environment
-  ** variable, or to the string "vi".
+  ** It defaults to the value of the VISUAL, or EDITOR, environment
+  ** variable, or to the string "vi" if neither of those are set.
   */
   { "encode_from",     DT_BOOL, R_NONE, OPTENCODEFROM, 0 },
   /*