From: Pierre Habouzit Date: Fri, 9 Mar 2007 23:29:31 +0000 (+0100) Subject: PoC support for lua. X-Git-Url: http://git.madism.org/?a=commitdiff_plain;h=06972cc96259a466cf14821d8b803bf3972d8fa2;p=apps%2Fmadmutt.git PoC support for lua. just source ~/.madmutt.lua or ~/.madmutt/cfg.lua Signed-off-by: Pierre Habouzit --- diff --git a/init.c b/init.c index da7227d..eb92e17 100644 --- a/init.c +++ b/init.c @@ -13,18 +13,18 @@ #include #include +#include #include #include - #include #include #include +#include #include "mutt.h" #include "keymap.h" #include "charset.h" #include "thread.h" -#include #include "mutt_idna.h" #if defined (USE_LIBESMTP) && (defined (USE_SSL) || defined (USE_GNUTLS)) @@ -2462,6 +2462,7 @@ void mutt_init (int skip_sys_rc, string_list_t * commands) From = rfc822_parse_adrlist (NULL, p); charset_initialize(); + mlua_initialize(); /* Set standard defaults */ hash_map (ConfigOptions, mutt_set_default, 0); @@ -2533,6 +2534,15 @@ void mutt_init (int skip_sys_rc, string_list_t * commands) exit (1); } + /* LUA {{{ */ + snprintf(buffer, sizeof(buffer), "%s/.madmutt.lua", NONULL(Homedir)); + if (access(buffer, F_OK) < 0) + snprintf(buffer, sizeof(buffer), "%s/.madmutt/cfg.lua", NONULL(Homedir)); + if (!access(buffer, F_OK)) { + need_pause = mlua_wrap(mutt_error, mlua_dofile(buffer)); + } + /* }}} */ + if (mutt_execute_commands (commands) != 0) need_pause = 1; diff --git a/lib-lua/Makefile.am b/lib-lua/Makefile.am index 92cd3d2..c30e6bc 100644 --- a/lib-lua/Makefile.am +++ b/lib-lua/Makefile.am @@ -1,6 +1,7 @@ noinst_LIBRARIES = liblua.a -liblua_a_SOURCES = lib-lua.h +liblua_a_SOURCES = lib-lua.h \ + runtime.c noinst_HEADERS = lib-lua.h diff --git a/lib-lua/lib-lua.h b/lib-lua/lib-lua.h index 0a4d859..8983322 100644 --- a/lib-lua/lib-lua.h +++ b/lib-lua/lib-lua.h @@ -24,5 +24,10 @@ # include "../config.h" #endif +void mlua_initialize(void); +void mlua_shutdown(void); + +int mlua_dofile(const char *filename); +int mlua_wrap(void (*errfun)(const char *fmt, ...), int status); #endif diff --git a/main.c b/main.c index 1c6982f..f452ba2 100644 --- a/main.c +++ b/main.c @@ -19,6 +19,7 @@ #include +#include #include #include #include @@ -850,5 +851,6 @@ int main (int argc, char **argv) mutt_endwin (Errorbuf); } + mlua_shutdown(); exit (0); }