1 diff -ru mutt-1.5.20/PATCHES mutt-ifdef/PATCHES
2 --- mutt-1.5.20/PATCHES 2010-07-11 18:58:14.152790042 -0400
3 +++ mutt-ifdef/PATCHES 2010-07-11 18:59:46.443148354 -0400
5 +patch-1.5.20.cd.ifdef.2
6 diff -ru mutt-1.5.20/doc/manual.xml.head mutt-ifdef/doc/manual.xml.head
7 --- mutt-1.5.20/doc/manual.xml.head 2010-07-11 18:58:14.139456668 -0400
8 +++ mutt-ifdef/doc/manual.xml.head 2010-07-11 19:04:34.976768877 -0400
14 +<title>Configuring features conditionnaly</title>
17 +<command>ifdef</command>
20 +<replaceable class="parameter">item</replaceable>
23 +<replaceable class="parameter">command</replaceable>
29 +This command allows to test if a feature has been compiled in, before
30 +actually executing the command. Item can be either the name of a
31 +function or a variable.
33 +Example: <literal><command>ifdef</command> imap_keepalive 'source ˜/.mutt/imap_setup'</literal>
38 <title>Removing Hooks</title>
40 diff -ru mutt-1.5.20/init.c mutt-ifdef/init.c
41 --- mutt-1.5.20/init.c 2010-07-11 18:58:14.109456715 -0400
42 +++ mutt-ifdef/init.c 2010-07-11 18:59:46.439468214 -0400
47 +static int parse_ifdef (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err)
52 + memset (&token, 0, sizeof (token));
53 + mutt_extract_token (tmp, s, 0);
55 + /* is the item defined as a variable or a function? */
56 + if (!(res = (mutt_option_index (tmp->data) != -1)))
57 + for (i = 0; !res && i < MENU_MAX; i++)
59 + struct binding_t *b = km_get_table (Menus[i].value);
64 + for (j = 0; b[j].name; j++)
65 + if (!ascii_strncasecmp (tmp->data, b[j].name, mutt_strlen (tmp->data))
66 + && (mutt_strlen (b[j].name) == mutt_strlen (tmp->data)))
75 + snprintf (err->data, err->dsize, _("ifdef: too few arguments"));
78 + mutt_extract_token (tmp, s, M_TOKEN_SPACE);
82 + if (mutt_parse_rc_line (tmp->data, &token, err) == -1)
84 + mutt_error ("Erreur: %s", err->data);
93 static int parse_unignore (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
96 diff -ru mutt-1.5.20/init.h mutt-ifdef/init.h
97 --- mutt-1.5.20/init.h 2010-07-11 18:58:14.159457593 -0400
98 +++ mutt-ifdef/init.h 2010-07-11 19:08:49.043007805 -0400
100 static int parse_unlists (BUFFER *, BUFFER *, unsigned long, BUFFER *);
101 static int parse_alias (BUFFER *, BUFFER *, unsigned long, BUFFER *);
102 static int parse_unalias (BUFFER *, BUFFER *, unsigned long, BUFFER *);
103 +static int parse_ifdef (BUFFER *, BUFFER *, unsigned long, BUFFER *);
104 static int parse_ignore (BUFFER *, BUFFER *, unsigned long, BUFFER *);
105 static int parse_unignore (BUFFER *, BUFFER *, unsigned long, BUFFER *);
106 static int parse_source (BUFFER *, BUFFER *, unsigned long, BUFFER *);
107 @@ -3719,6 +3720,7 @@
108 { "group", parse_group, 0 },
109 { "ungroup", parse_ungroup, 0 },
110 { "hdr_order", parse_list, UL &HeaderOrderList },
111 + { "ifdef", parse_ifdef, 0 },
113 { "iconv-hook", mutt_parse_hook, M_ICONVHOOK },