]> granicus.if.org Git - mutt/commitdiff
Add a display-hook command. From Byrial Jensen.
authorThomas Roessler <roessler@does-not-exist.org>
Sat, 20 May 2000 07:50:24 +0000 (07:50 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Sat, 20 May 2000 07:50:24 +0000 (07:50 +0000)
commands.c
hook.c
init.h
mutt.h
protos.h
send.c

index 43b0d2fb0b64a83e9a76def1839bd5adb6b17a3d..8978e8eadf2c01ddaad2432c10c0ca5e3906f67a 100644 (file)
 
 
 
-
-
-
-
-
-
-
-
 #include <errno.h>
 #include <unistd.h>
 #include <stdlib.h>
@@ -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 e44bd03e6f4f140d2cd825222e076580a5cdec96..5b37fe7df1627a805d4f3c566a522dbcd35a451d 100644 (file)
--- 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 2fe274d0cc28bb1eb99dfadd6b00e24457abb32d..f4c0209b9afde9bec6a1345b15d44b79d85c7e5e 100644 (file)
--- 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 75652cf5cd106a8d93f5d7ec44a7a865a7cb0029..49018d721c4d56c3e03f6f3409f8f6766c9b7775 100644 (file)
--- 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 */
index 63879250592250a91e2fbdd26e87212c55bfc075..b988e6f0b4009212ea1beede64b6cad26bef0098 100644 (file)
--- 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 21526326b48adc4c95c1832a4f32f2829d08653b..6f77afb1e25e89f24ba7fbb7f6d7995467d71c47 100644 (file)
--- 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)
     {