Skip to content

Commit

Permalink
Adding basic Lua scripting basics to mutt
Browse files Browse the repository at this point in the history
* adding two commands:
 - lua: to parse a line of lua code
 - lua-source: to load and parse a lua file
* binding two mutt functions in lua:
 - mutt_message and
 - mutt_error

cf #153

Signed-off-by: Guyzmo <guyzmo+github+pub@m0g.net>
  • Loading branch information
guyzmo committed Feb 25, 2017
1 parent 08f79e5 commit 075d7e7
Show file tree
Hide file tree
Showing 9 changed files with 260 additions and 156 deletions.
4 changes: 2 additions & 2 deletions Makefile.am
Expand Up @@ -69,7 +69,7 @@ EXTRA_mutt_SOURCES = account.c bcache.c compress.c crypt-gpgme.c crypt-mod-pgp-c
mutt_idna.c mutt_sasl.c mutt_socket.c mutt_ssl.c mutt_ssl_gnutls.c \
mutt_tunnel.c pgp.c pgpinvoke.c pgpkey.c pgplib.c pgpmicalg.c \
pgppacket.c pop.c pop_auth.c pop_lib.c remailer.c resize.c sha1.c \
mutt-lua.c nntp.c newsrc.c \
mutt_lua.c nntp.c newsrc.c \
sidebar.c smime.c smtp.c utf8.c wcwidth.c \
bcache.h browser.h hcache.h mbyte.h mutt_idna.h remailer.h url.h

Expand All @@ -81,7 +81,7 @@ EXTRA_DIST = COPYRIGHT LICENSE.md OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO UPDATING
mutt_regex.h mutt_sasl.h mutt_sasl_plain.h mutt_socket.h mutt_ssl.h \
mutt_tunnel.h mx.h pager.h pgp.h pop.h protos.h rfc1524.h rfc2047.h \
rfc2231.h rfc822.h rfc3676.h sha1.h sort.h mime.types \
mutt-lua.h nntp.h ChangeLog.nntp \
mutt_lua.h nntp.h ChangeLog.nntp \
_regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \
mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h \
README.SSL README.md README.neomutt README.notmuch smime.h group.h \
Expand Down
8 changes: 4 additions & 4 deletions configure.ac
Expand Up @@ -302,10 +302,10 @@ AX_LUA_HEADERS(:,enable_lua=no)
AX_LUA_LIBS(:,enable_lua=no)

AS_IF([test x$enable_lua = "xyes"], [
AC_DEFINE(USE_LUA, 1, [Define if you want support for LUA.])
MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS mutt-lua.o"
CPPFLAGS="$CPPFLAGS $LUA_INCLUDE"
LIBS="$LIBS $LUA_LIB"
AC_DEFINE(USE_LUA, 1, [Define if you want support for LUA.])
MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS mutt_lua.o"
CPPFLAGS="$CPPFLAGS $LUA_INCLUDE"
LIBS="$LIBS $LUA_LIB"
])
AM_CONDITIONAL(BUILD_LUA, test x$enable_lua = xyes)

Expand Down
8 changes: 0 additions & 8 deletions curs_main.c
Expand Up @@ -52,9 +52,6 @@
#include "nntp.h"
#endif

#ifdef USE_LUA
#include "mutt-lua.h"
#endif

#include <ctype.h>
#include <stdlib.h>
Expand Down Expand Up @@ -3213,11 +3210,6 @@ int mutt_index_menu (void)
case OP_SIDEBAR_TOGGLE_VIRTUAL:
mutt_sb_toggle_virtual();
break;
#endif
#ifdef USE_LUA
case OP_LUA_RUN:
lua_test();
break;
#endif
default:
if (menu->menu == MENU_MAIN)
Expand Down
3 changes: 0 additions & 3 deletions functions.h
Expand Up @@ -129,9 +129,6 @@ const struct binding_t OpMain[] = { /* map: index */
{ "limit-current-thread", OP_LIMIT_CURRENT_THREAD, NULL },
{ "link-threads", OP_MAIN_LINK_THREADS, "&" },
{ "list-reply", OP_LIST_REPLY, "L" },
#ifdef USE_LUA
{ "lua-run", OP_LUA_RUN, NULL },
#endif
{ "mail", OP_MAIL, "m" },
{ "toggle-new", OP_TOGGLE_NEW, "N" },
{ "toggle-write", OP_TOGGLE_WRITE, "%" },
Expand Down
3 changes: 0 additions & 3 deletions globals.h
Expand Up @@ -70,9 +70,6 @@ WHERE char *ImapUser INITVAL (NULL);
#endif
WHERE char *Inbox;
WHERE char *Ispell;
#ifdef USE_LUA
WHERE char *LuaScript;
#endif
WHERE char *MailcapPath;
WHERE char *Maildir;
#if defined(USE_IMAP) || defined(USE_POP) || defined(USE_NNTP)
Expand Down
15 changes: 8 additions & 7 deletions init.h
Expand Up @@ -25,6 +25,10 @@
# include "mx.h"
#endif

#ifdef USE_LUA
#include "mutt_lua.h"
#endif

#include "buffy.h"

#ifndef _MAKEDOC
Expand Down Expand Up @@ -1604,13 +1608,6 @@ struct option_t MuttVars[] = {
** ``$$keywords_standard'' are \fCfalse\fP, mutt will save keywords
** to legacy headers to ensure that it does not lose your labels.
*/
#ifdef USE_LUA
{ "lua_script", DT_STR, R_NONE, UL &LuaScript, 0 },
/*
** .pp
** External Lua script to run.
*/
#endif
{ "mail_check", DT_NUM, R_NONE, UL &BuffyTimeout, 5 },
/*
** .pp
Expand Down Expand Up @@ -4487,6 +4484,10 @@ const struct command_t Commands[] = {
#endif
{ "ignore", parse_ignore, 0 },
{ "lists", parse_lists, 0 },
#ifdef USE_LUA
{ "lua", mutt_lua_parse, 0 },
{ "lua-source", mutt_lua_source_file, 0 },
#endif
{ "macro", mutt_parse_macro, 0 },
{ "mailboxes", mutt_parse_mailboxes, MUTT_MAILBOXES },
{ "unmailboxes", mutt_parse_mailboxes, MUTT_UNMAILBOXES },
Expand Down
128 changes: 0 additions & 128 deletions mutt-lua.c

This file was deleted.

0 comments on commit 075d7e7

Please sign in to comment.