Now deal with EDITOR from lua as well.
[apps/madmutt.git] / lib-lua / madmutt.c
index 4bb0095..3bd3428 100644 (file)
@@ -75,7 +75,11 @@ static int madmutt_assign(lua_State *L)
       case LTK_SENDMAIL:
       case LTK_SHELL:
         _mutt_expand_path(buf, sizeof(buf), val, 0);
       case LTK_SENDMAIL:
       case LTK_SHELL:
         _mutt_expand_path(buf, sizeof(buf), val, 0);
-        mlua_regsets(tk, buf);
+        val = buf;
+        /* FALLTHROUGH */
+
+      case LTK_EDITOR:
+        mlua_regsets(tk, val);
         return 0;
     }
 }
         return 0;
     }
 }
@@ -196,6 +200,12 @@ static const struct {
 
 /* {{{ madmutt magic properties */
 
 
 /* {{{ madmutt magic properties */
 
+static void madmutt_init_editor(char *buf, ssize_t len)
+{
+    m_strcpy(buf, len, getenv("VISUAL") ?: getenv("EDITOR") ?: "vi");
+    fprintf("%s\n", buf);
+}
+
 static void madmutt_init_shell(char *buf, ssize_t len)
 {
     struct passwd *pw = getpwuid(getuid());
 static void madmutt_init_shell(char *buf, ssize_t len)
 {
     struct passwd *pw = getpwuid(getuid());
@@ -219,6 +229,13 @@ static const struct {
      ** Contains the path of the \fTmadmutt_dotlock(1)\fP binary to be used by
      ** Madmutt.
      */
      ** Contains the path of the \fTmadmutt_dotlock(1)\fP binary to be used by
      ** Madmutt.
      */
+    {"editor",       madmutt_init_editor, NULL },
+    /*
+     ** .pp
+     ** This variable specifies which editor is used by Madmutt.
+     ** It defaults to the value of the \fT$$$VISUAL\fP, or \fT$$$EDITOR\fP, environment
+     ** variable, or to the string "\fTvi\fP" if neither of those are set.
+     */
     { "sendmail",    NULL, SENDMAIL " -oem -oi" },
     /*
      ** .pp
     { "sendmail",    NULL, SENDMAIL " -oem -oi" },
     /*
      ** .pp