2 This is the ifdef patch by Cedric Duval <cedricduval@free.fr>.
4 This command allows to test if a feature has been compiled in before actually
5 attempting to configure / use it.
11 where <item> can be the name of a variable, function, or command.
15 ifdef imap-fetch-mail 'source ~/.mutt/imap_setup'
16 ifdef trash set trash=~/Mail/trash
18 * Patch last synced with upstream:
21 http://cedricduval.free.fr/mutt/patches/download/patch-1.5.4.cd.ifdef.1
25 - Also look for commands
26 - Use mutt_strcmp in favor of ascii_strncasecmp to compare strings.
30 ===================================================================
31 --- mutt.orig/init.c 2006-12-12 14:15:03.000000000 +0100
32 +++ mutt/init.c 2007-02-15 23:38:45.597907432 +0100
33 @@ -624,6 +624,65 @@ static int remove_from_rx_list (RX_LIST
37 +static int parse_ifdef (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err)
42 + memset (&token, 0, sizeof (token));
43 + mutt_extract_token (tmp, s, 0);
45 + /* is the item defined as a variable? */
46 + res = (mutt_option_index (tmp->data) != -1);
50 + for (i = 0; !res && i < MENU_MAX; i++)
52 + struct binding_t *b = km_get_table (Menus[i].value);
57 + for (j = 0; b[j].name; j++)
58 + if (!mutt_strcmp (tmp->data, b[j].name))
67 + for (i = 0; Commands[i].name; i++)
69 + if (!mutt_strcmp (tmp->data, Commands[i].name))
78 + snprintf (err->data, err->dsize, _("ifdef: too few arguments"));
81 + mutt_extract_token (tmp, s, M_TOKEN_SPACE);
85 + if (mutt_parse_rc_line (tmp->data, &token, err) == -1)
87 + mutt_error ("Erreur: %s", err->data);
96 static int parse_unignore (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
100 ===================================================================
101 --- mutt.orig/init.h 2006-12-12 14:15:03.000000000 +0100
102 +++ mutt/init.h 2007-02-15 23:26:21.160079184 +0100
103 @@ -3017,6 +3017,7 @@ static int parse_lists (BUFFER *, BUFFER
104 static int parse_unlists (BUFFER *, BUFFER *, unsigned long, BUFFER *);
105 static int parse_alias (BUFFER *, BUFFER *, unsigned long, BUFFER *);
106 static int parse_unalias (BUFFER *, BUFFER *, unsigned long, BUFFER *);
107 +static int parse_ifdef (BUFFER *, BUFFER *, unsigned long, BUFFER *);
108 static int parse_ignore (BUFFER *, BUFFER *, unsigned long, BUFFER *);
109 static int parse_unignore (BUFFER *, BUFFER *, unsigned long, BUFFER *);
110 static int parse_source (BUFFER *, BUFFER *, unsigned long, BUFFER *);
111 @@ -3068,6 +3069,7 @@ struct command_t Commands[] = {
112 { "group", parse_group, 0 },
113 { "ungroup", parse_ungroup, 0 },
114 { "hdr_order", parse_list, UL &HeaderOrderList },
115 + { "ifdef", parse_ifdef, 0 },
117 { "iconv-hook", mutt_parse_hook, M_ICONVHOOK },
120 ===================================================================
121 --- mutt/PATCHES.orig 2007-02-15 21:48:09.131803632 +0100
122 +++ mutt/PATCHES 2007-02-15 21:48:09.131803632 +0100
124 +patch-1.5.13.cd.ifdef.2
125 Index: mutt/doc/manual.xml.head
126 ===================================================================
127 --- mutt.orig/doc/manual.xml.head 2007-02-15 21:53:09.312169280 +0100
128 +++ mutt/doc/manual.xml.head 2007-02-15 23:42:23.875724160 +0100
129 @@ -3091,6 +3091,28 @@ considered to be an executable program f
135 +<title>Configuring features conditionnaly</title>
138 +Usage: <literal>ifdef</literal> <emphasis>item</emphasis> <emphasis>command</emphasis>
142 +This command allows to test if a feature has been compiled in, before
143 +actually executing the command. Item can be either the name of a
144 +function, variable, or command. Example:
149 +ifdef imap_keepalive 'source ~/.mutt/imap_setup'
156 <title>Removing hooks</title>