From 51bce657a095a3c79618df01e92f5e69b07fe986 Mon Sep 17 00:00:00 2001 From: Thomas Roessler Date: Sat, 20 May 2000 07:50:24 +0000 Subject: [PATCH] Add a display-hook command. From Byrial Jensen. --- commands.c | 10 ++-------- hook.c | 22 +++++++++++----------- init.h | 4 +++- mutt.h | 3 ++- protos.h | 2 +- send.c | 2 +- 6 files changed, 20 insertions(+), 23 deletions(-) diff --git a/commands.c b/commands.c index 43b0d2fb..8978e8ea 100644 --- a/commands.c +++ b/commands.c @@ -42,14 +42,6 @@ - - - - - - - - #include #include #include @@ -115,6 +107,8 @@ int mutt_display_message (HEADER *cur) return (0); } + mutt_message_hook (cur, M_DISPLAYHOOK); + if (!Pager || mutt_strcmp (Pager, "builtin") == 0) builtin = 1; else diff --git a/hook.c b/hook.c index e44bd03e..5b37fe7d 100644 --- a/hook.c +++ b/hook.c @@ -115,11 +115,11 @@ int mutt_parse_hook (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) ptr->rx.not == not && !mutt_strcmp (pattern.data, ptr->rx.pattern)) { - if (data & (M_FOLDERHOOK | M_SENDHOOK)) + if (data & (M_FOLDERHOOK | M_SENDHOOK | M_DISPLAYHOOK)) { - /* folder-hook and send-hook allow multiple commands with the same - pattern, so if we've already seen this pattern/command pair, just - ignore it instead of creating a duplicate */ + /* these hooks allow multiple commands with the same + * pattern, so if we've already seen this pattern/command pair, just + * ignore it instead of creating a duplicate */ if (!mutt_strcmp (ptr->command, command.data)) { FREE (&command.data); @@ -130,10 +130,10 @@ int mutt_parse_hook (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) 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 - a common action to perform is to change the default (.) entry - based upon some other information. */ + * entry with the new command. this currently does not change the + * order of execution of the hooks, which i think is desirable since + * a common action to perform is to change the default (.) entry + * based upon some other information. */ FREE (&ptr->command); ptr->command = command.data; FREE (&pattern.data); @@ -144,7 +144,7 @@ int mutt_parse_hook (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) break; } - if (data & (M_SENDHOOK | M_SAVEHOOK | M_FCCHOOK)) + if (data & (M_SENDHOOK | M_SAVEHOOK | M_FCCHOOK | M_DISPLAYHOOK)) { if ((pat = mutt_pattern_comp (pattern.data, (data & (M_SENDHOOK | M_FCCHOOK)) ? 0 : M_FULL_MSG, err)) == NULL) goto error; @@ -292,7 +292,7 @@ char *mutt_find_hook (int type, const char *pat) return (NULL); } -void mutt_send_hook (HEADER *hdr) +void mutt_message_hook (HEADER *hdr, int type) { BUFFER err, token; HOOK *hook; @@ -306,7 +306,7 @@ void mutt_send_hook (HEADER *hdr) if(!hook->command) continue; - if (hook->type & M_SENDHOOK) + if (hook->type & type) if ((mutt_pattern_exec (hook->pattern, 0, NULL, hdr) > 0) ^ hook->rx.not) if (mutt_parse_rc_line (hook->command, &token, &err) != 0) { diff --git a/init.h b/init.h index 2fe274d0..f4c0209b 100644 --- a/init.h +++ b/init.h @@ -345,7 +345,8 @@ struct option_t MuttVars[] = { { "default_hook", DT_STR, R_NONE, UL &DefaultHook, UL "~f %s !~P | (~P ~C %s)" }, /* ** .pp - ** This variable controls how send-hooks, save-hooks, and fcc-hooks will + ** This variable controls how send-hooks, display-hooks, save-hooks, + ** and fcc-hooks will ** be interpreted if they are specified with only a simple regexp, ** instead of a matching pattern. The hooks are expanded when they are ** declared, so a hook will be interpreted according to the value of this @@ -2231,6 +2232,7 @@ struct command_t Commands[] = { { "color", mutt_parse_color, 0 }, { "uncolor", mutt_parse_uncolor, 0 }, #endif + { "display-hook", mutt_parse_hook, M_DISPLAYHOOK }, { "exec", mutt_parse_exec, 0 }, { "fcc-hook", mutt_parse_hook, M_FCCHOOK }, { "fcc-save-hook", mutt_parse_hook, M_FCCHOOK | M_SAVEHOOK }, diff --git a/mutt.h b/mutt.h index 75652cf5..49018d72 100644 --- a/mutt.h +++ b/mutt.h @@ -129,8 +129,9 @@ typedef enum #define M_FCCHOOK (1<<3) #define M_SAVEHOOK (1<<4) #define M_CHARSETHOOK (1<<5) +#define M_DISPLAYHOOK (1<<6) #ifdef HAVE_PGP -#define M_PGPHOOK (1<<6) +#define M_PGPHOOK (1<<7) #endif /* tree characters for linearize_tree and print_enriched_string */ diff --git a/protos.h b/protos.h index 63879250..b988e6f0 100644 --- a/protos.h +++ b/protos.h @@ -197,7 +197,7 @@ void mutt_score_message (CONTEXT *, HEADER *, int); void mutt_select_fcc (char *, size_t, HEADER *); #define mutt_select_file(A,B,C) _mutt_select_file(A,B,C,0,NULL,NULL) void _mutt_select_file (char *, size_t, int, int, char ***, int *); -void mutt_send_hook (HEADER *); +void mutt_message_hook (HEADER *, int); void _mutt_set_flag (CONTEXT *, HEADER *, int, int, int); #define mutt_set_flag(a,b,c,d) _mutt_set_flag(a,b,c,d,1) void mutt_set_followup_to (ENVELOPE *); diff --git a/send.c b/send.c index 21526326..6f77afb1 100644 --- a/send.c +++ b/send.c @@ -1148,7 +1148,7 @@ ci_send_message (int flags, /* send mode */ /* change settings based upon recipients */ - mutt_send_hook (msg); + mutt_message_hook (msg, M_SENDHOOK); if (killfrom) { -- 2.40.0