PoC support for lua.
[apps/madmutt.git] / init.c
diff --git a/init.c b/init.c
index 82636f1..eb92e17 100644 (file)
--- a/init.c
+++ b/init.c
 #include <lib-lib/lib-lib.h>
 #include <sys/utsname.h>
 
+#include <lib-lua/lib-lua.h>
 #include <lib-sys/unix.h>
 #include <lib-sys/mutt_ssl.h>
-
 #include <lib-ui/curses.h>
 #include <lib-ui/history.h>
 #include <lib-mx/mx.h>
+#include <lib-crypt/crypt.h>
 
 #include "mutt.h"
 #include "keymap.h"
 #include "charset.h"
 #include "thread.h"
-#include <lib-crypt/crypt.h>
 #include "mutt_idna.h"
 
 #if defined (USE_LIBESMTP) && (defined (USE_SSL) || defined (USE_GNUTLS))
@@ -732,9 +732,8 @@ static int parse_ignore (BUFFER * buf, BUFFER * s,
   return 0;
 }
 
-static int parse_list (BUFFER * buf, BUFFER * s,
-                       unsigned long data __attribute__ ((unused)),
-                       BUFFER * err __attribute__ ((unused)))
+static int parse_list(BUFFER * buf, BUFFER * s, unsigned long data,
+                      BUFFER * err __attribute__ ((unused)))
 {
   do {
     mutt_extract_token (buf, s, 0);
@@ -1251,8 +1250,7 @@ static int parse_alias (BUFFER * buf, BUFFER * s,
             set_option (OPTFORCEREDRAWINDEX);
     }
 
-    mutt_extract_token(buf, s,
-                       M_TOKEN_QUOTE | M_TOKEN_SPACE | M_TOKEN_SEMICOLON);
+    mutt_extract_token(buf, s, M_TOKEN_QUOTE | M_TOKEN_SPACE);
     (*last)->addr = mutt_parse_adrlist((*last)->addr, buf->data);
     if (mutt_addrlist_to_idna((*last)->addr, &estr)) {
         snprintf (err->data, err->dsize,
@@ -1928,7 +1926,7 @@ static int parse_source (BUFFER * tmp, BUFFER * s,
                every call to this function.
 
    err         where to write error messages */
-int mutt_parse_rc_line ( /* const */ char *line, BUFFER * token, BUFFER * err)
+int mutt_parse_rc_line (const char *line, BUFFER * token, BUFFER * err)
 {
   int i, r = -1;
   BUFFER expn;
@@ -2464,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);
@@ -2535,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;