considered to be an executable program from which to read input (eg.
<tt/source ~/bin/myscript|/).
+<sect1>Removing hooks<label id="unhook">
+<p>
+Usage: <tt/unhook/ [ * | <em/hook-type/ ]
+
+This command permits you to flush hooks you have previously defined.
+You can either remove all hooks by giving the ``*'' character as an
+argument, or you can remove all hooks of a specific type by saying
+something like <tt/unhook send-hook/.
+
<sect>Advanced Usage
<sect1>Regular Expressions<label id="regexp">
.TP
\fBsource\fP \fIfilename\fP
The given file will be evaluated as a configuration file.
+.TP
+\fBunhook\fP [\fB * \fP | \fIhook-type\fP ]
+This command will remove all hooks of a given type, or all hooks
+when \(lq\fB*\fP\(rq is used as an argument. \fIhook-type\fP
+can be any of the \fB-hook\fP commands documented above.
.SH PATTERNS
.PP
In various places with mutt, including some of the abovementioned
return (-1);
}
+static void delete_hook (HOOK *h)
+{
+ FREE (&h->command);
+ FREE (&h->rx.pattern);
+ if (h->rx.rx)
+ {
+ regfree (h->rx.rx);
+ }
+ mutt_pattern_free (&h->pattern);
+ FREE (&h);
+}
+
+/* Deletes all hooks of type ``type'', or all defined hooks if ``type'' is 0 */
+static void delete_hooks (int type)
+{
+ HOOK *h;
+ HOOK *prev;
+
+ while (h = Hooks, h && (type == 0 || type == h->type))
+ {
+ Hooks = h->next;
+ delete_hook (h);
+ }
+
+ prev = h; /* Unused assignment to avoid compiler warnings */
+
+ while (h)
+ {
+ if (type == h->type)
+ {
+ prev->next = h->next;
+ delete_hook (h);
+ }
+ else
+ prev = h;
+ h = prev->next;
+ }
+}
+
+int mutt_parse_unhook (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
+{
+ while (MoreArgs (s))
+ {
+ mutt_extract_token (buf, s, 0);
+ if (mutt_strcmp ("*", buf->data) == 0)
+ delete_hooks (0);
+ else
+ {
+ int type = mutt_get_hook_type (buf->data);
+ if (type)
+ delete_hooks (type);
+ else
+ {
+ snprintf (err->data, err->dsize,
+ _("unhook: unknown hook type: %s"), buf->data);
+ return (-1);
+ }
+ }
+ }
+ return 0;
+}
+
void mutt_folder_hook (char *path)
{
HOOK *tmp = Hooks;
set_option (OPTWEED); /* turn weeding on by default */
#endif
}
+
+int mutt_get_hook_type (const char *name)
+{
+ struct command_t *c;
+
+ for (c = Commands ; c->name ; c++)
+ if (c->func == mutt_parse_hook && mutt_strcasecmp (c->name, name) == 0)
+ return c->data;
+ return 0;
+}
{ "toggle", parse_set, M_SET_INV },
{ "unalias", parse_unalias, 0 },
{ "unhdr_order", parse_unlist, UL &HeaderOrderList },
+ { "unhook", mutt_parse_unhook, 0 },
{ "unignore", parse_unignore, 0 },
{ "unlists", parse_unlists, 0 },
{ "unmono", mutt_parse_unmono, 0 },
int _mutt_enter_string (unsigned char *, size_t, int, int, int, int, char ***, int *);
#define mutt_get_field(A,B,C,D) _mutt_get_field(A,B,C,D,0,NULL,NULL)
int _mutt_get_field (char *, char *, size_t, int, int, char ***, int *);
+int mutt_get_hook_type (const char *);
int mutt_get_password (char *, char *, size_t);
int mutt_get_postponed (CONTEXT *, HEADER *, HEADER **, char *, size_t);
int mutt_get_tmp_attachment (BODY *);
int mutt_parse_rc_line (/* const */ char *, BUFFER *, BUFFER *);
int mutt_parse_score (BUFFER *, BUFFER *, unsigned long, BUFFER *);
int mutt_parse_unscore (BUFFER *, BUFFER *, unsigned long, BUFFER *);
+int mutt_parse_unhook (BUFFER *, BUFFER *, unsigned long, BUFFER *);
int mutt_pattern_func (int, char *);
int mutt_pipe_attachment (FILE *, BODY *, const char *, char *);
int mutt_pipe_message (HEADER *);