NeoMutt  2025-12-11-911-gd8d604
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
commands.c File Reference

Lua Commands. More...

#include "config.h"
#include <lauxlib.h>
#include <lua.h>
#include <stdbool.h>
#include <stdio.h>
#include "mutt/lib.h"
#include "core/lib.h"
#include "lib.h"
#include "parse/lib.h"
#include "module_data.h"
#include "muttlib.h"
+ Include dependency graph for commands.c:

Go to the source code of this file.

Macros

#define LUA_COMPAT_ALL
 
#define LUA_COMPAT_5_1
 

Functions

bool lua_init_state (lua_State **l)
 Initialise a Lua State.
 
enum CommandResult parse_lua (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'lua' command - Implements Command::parse() -.
 
enum CommandResult parse_lua_source (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'lua-source' command - Implements Command::parse() -.
 

Variables

const struct Command LuaCommands []
 List of NeoMutt commands to register.
 

Detailed Description

Lua Commands.

Authors
  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file commands.c.

Macro Definition Documentation

◆ LUA_COMPAT_ALL

#define LUA_COMPAT_ALL

Definition at line 30 of file commands.c.

◆ LUA_COMPAT_5_1

#define LUA_COMPAT_5_1

Definition at line 33 of file commands.c.

Function Documentation

◆ lua_init_state()

bool lua_init_state ( lua_State ** l)

Initialise a Lua State.

Parameters
[out]lLua State
Return values
trueSuccessful

Definition at line 443 of file lua.c.

444{
445 if (!l)
446 return false;
447 if (*l)
448 return true;
449
450 mutt_debug(LL_DEBUG2, "enter\n");
451 *l = luaL_newstate();
452
453 if (!*l)
454 {
455 mutt_error(_("Error: Couldn't load the lua interpreter"));
456 return false;
457 }
458
459 lua_atpanic(*l, lua_handle_panic);
460
461 /* load various Lua libraries */
462 luaL_openlibs(*l);
463 lua_expose_mutt(*l);
464
465 return true;
466}
#define mutt_error(...)
Definition logging2.h:94
#define mutt_debug(LEVEL,...)
Definition logging2.h:91
@ LL_DEBUG2
Log at debug level 2.
Definition logging2.h:46
static void lua_expose_mutt(lua_State *l)
Expose a 'Mutt' object to the Lua interpreter.
Definition lua.c:424
static int lua_handle_panic(lua_State *l)
Handle a panic in the Lua interpreter.
Definition lua.c:60
#define _(a)
Definition message.h:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ LuaCommands

const struct Command LuaCommands[]
Initial value:
= {
{ "lua", CMD_LUA, parse_lua,
N_("Run a Lua expression or call a Lua function"),
N_("lua <lua-command>"),
"optionalfeatures.html#lua" },
{ "lua-source", CMD_LUA_SOURCE, parse_lua_source,
N_("Execute a Lua script file"),
N_("lua-source <filename>"),
"optionalfeatures.html#lua" },
{ NULL, CMD_NONE, NULL, NULL, NULL, NULL, CF_NONE },
}
@ CF_NONE
No flags are set.
Definition command.h:49
@ CMD_LUA_SOURCE
:lua-source
Definition command.h:92
@ CMD_LUA
:lua
Definition command.h:91
@ CMD_NONE
No Command.
Definition command.h:62
enum CommandResult parse_lua_source(const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
Parse the 'lua-source' command - Implements Command::parse() -.
Definition commands.c:99
enum CommandResult parse_lua(const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
Parse the 'lua' command - Implements Command::parse() -.
Definition commands.c:56
#define N_(a)
Definition message.h:32

List of NeoMutt commands to register.

Definition at line 151 of file commands.c.

151 {
152 // clang-format off
153 { "lua", CMD_LUA, parse_lua,
154 N_("Run a Lua expression or call a Lua function"),
155 N_("lua <lua-command>"),
156 "optionalfeatures.html#lua" },
157 { "lua-source", CMD_LUA_SOURCE, parse_lua_source,
158 N_("Execute a Lua script file"),
159 N_("lua-source <filename>"),
160 "optionalfeatures.html#lua" },
161
162 { NULL, CMD_NONE, NULL, NULL, NULL, NULL, CF_NONE },
163 // clang-format on
164};