X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=hook.c;h=0e6a689a5b1adcaf3089cc543a993af020eda10b;hp=a84dc001a625e2bde176a7b6e3fc3fbd4497a87b;hb=ffb2d4f3705ffc083472d04a3c58146b6bc8bfea;hpb=80566f6aedda1e4bdcca38f9cb27101b5ba1029f diff --git a/hook.c b/hook.c index a84dc00..0e6a689 100644 --- a/hook.c +++ b/hook.c @@ -8,12 +8,13 @@ */ #include +#include #include #include #include -#include #include "alias.h" +#include "crypt.h" #include "pattern.h" typedef struct hook_t { @@ -122,8 +123,7 @@ int mutt_parse_hook (BUFFER * buf __attribute__ ((unused)), BUFFER * s, p_delete(&pattern.data); return 0; } - } - else { + } else { /* other hooks only allow one command per pattern, so update the * entry with the new command. this currently does not change the * order of execution of the hooks, which i think is desirable since @@ -139,18 +139,16 @@ int mutt_parse_hook (BUFFER * buf __attribute__ ((unused)), BUFFER * s, break; } - if (data & - (M_SENDHOOK | M_SEND2HOOK | M_SAVEHOOK | M_FCCHOOK | M_MESSAGEHOOK | - M_REPLYHOOK)) { + if (data & (M_SENDHOOK | M_SEND2HOOK | M_SAVEHOOK | M_FCCHOOK | + M_MESSAGEHOOK | M_REPLYHOOK)) + { if ((pat = mutt_pattern_comp (pattern.data, (data & (M_SENDHOOK | M_SEND2HOOK | M_FCCHOOK)) ? 0 : M_FULL_MSG, err)) == NULL) goto error; - } - else { + } else { rx = p_new(regex_t, 1); -#ifdef M_CRYPTHOOK if ((rc = REGCOMP(rx, NONULL(pattern.data), ((data & M_CRYPTHOOK) ? REG_ICASE : 0))) != 0) { @@ -159,15 +157,14 @@ int mutt_parse_hook (BUFFER * buf __attribute__ ((unused)), BUFFER * s, p_delete(&rx); goto error; } -#endif /* M_CRYPTHOOK */ } if (ptr) { ptr->next = p_new(hook_t, 1); ptr = ptr->next; - } - else + } else { Hooks = ptr = p_new(hook_t, 1); + } ptr->type = data; ptr->command = command.data; ptr->pattern = pat; @@ -256,6 +253,20 @@ void mutt_folder_hook (char *path) p_delete(&token.data); current_hook_type = 0; + + { + lua_State *L = luaM_getruntime(); + lua_getfield(L, LUA_GLOBALSINDEX, "MCore"); + lua_getfield(L, -1, "folder_hook"); + lua_remove(L, -2); + if (lua_isfunction(L, -1)) { + lua_pushstring(L, LastFolder); + lua_pushstring(L, CurrentFolder); + lua_pcall(L, 2, 0, 0); + } else { + lua_pop(L, 1); + } + } } char *mutt_find_hook (int type, const char *pat) @@ -356,10 +367,10 @@ void mutt_select_fcc (char *path, ssize_t pathlen, HEADER * hdr) mutt_safe_path (buf, sizeof (buf), adr); mutt_concat_path(path, pathlen, NONULL(Maildir), buf); if (!option (OPTFORCENAME) && mx_access (path, W_OK) != 0) - m_strcpy(path, pathlen, NONULL(Outbox)); + m_strcpy(path, pathlen, NONULL(MAlias.record)); } else - m_strcpy(path, pathlen, NONULL(Outbox)); + m_strcpy(path, pathlen, NONULL(MAlias.record)); } mutt_pretty_mailbox (path); }