X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=lib-lua%2Fmadmutt.c;h=29907f3024f4c77a296824b4b3205ac69bbc5e26;hb=0dd5b492f18e549ef95b0ac6765329473e426633;hp=3bd3428b629329660ab56406a2440381c6b28492;hpb=488a60c8ef78872f38bbb3439a75cb2cda985a12;p=apps%2Fmadmutt.git diff --git a/lib-lua/madmutt.c b/lib-lua/madmutt.c index 3bd3428..29907f3 100644 --- a/lib-lua/madmutt.c +++ b/lib-lua/madmutt.c @@ -58,6 +58,19 @@ static int madmutt_folder_name(lua_State *L) return 1; } +static quadopt_t quadopt_parse(const char *s) +{ + if (!m_strcasecmp("yes", s)) + return M_YES; + if (!m_strcasecmp("no", s)) + return M_NO; + if (!m_strcasecmp("ask-yes", s)) + return M_ASKYES; + if (!m_strcasecmp("ask-no", s)) + return M_ASKNO; + return -1; +} + static int madmutt_assign(lua_State *L) { const char *idx = luaL_checkstring(L, 2); @@ -66,21 +79,28 @@ static int madmutt_assign(lua_State *L) switch ((tk = lua_which_token(idx, -1))) { char buf[STRING]; + int i; default: - luaL_error(L, "read-only or inexistant property '%s'", idx, tk); - return 0; + return luaL_error(L, "read-only or inexistant property '%s'", idx, tk); case LTK_DOTLOCK: case LTK_SENDMAIL: case LTK_SHELL: + case LTK_EDITOR: _mutt_expand_path(buf, sizeof(buf), val, 0); val = buf; /* FALLTHROUGH */ - case LTK_EDITOR: mlua_regsets(tk, val); return 0; + + case LTK_QUIT: + i = quadopt_parse(val); + if (i < 0) + return luaL_error(L, "invalid quad option value: '%s'", val); + mlua_regsetq(tk, i); + return 0; } } @@ -203,7 +223,6 @@ static const struct { 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) @@ -249,6 +268,14 @@ static const struct { ** Command to use when spawning a subshell. By default, the user's login ** shell from \fT/etc/passwd\fP is used. */ + {"quit", NULL, "yes" } + /* + ** .pp + ** This variable controls whether ``quit'' and ``exit'' actually quit + ** from Madmutt. If it set to \fIyes\fP, they do quit, if it is set to \fIno\fP, they + ** have no effect, and if it is set to \fIask-yes\fP or \fIask-no\fP, you are + ** prompted for confirmation when you try to quit. + */ }; /* }}} */