File patch-1.5.4.cd.ifdef.1 of Package mutt
Index: mutt-1.5.21/doc/manual.xml.head
===================================================================
--- mutt-1.5.21.orig/doc/manual.xml.head
+++ mutt-1.5.21/doc/manual.xml.head
@@ -4372,8 +4372,39 @@ from which to read input (e.g. <literal
</para>
</sect1>
+<sect1 id="ifdef">
+<title>Configuring features conditionally</title>
+<para>
+Usage:
+</para>
+<cmdsynopsis>
+<command>ifdef</command>
+<group choice="req">
+<arg choice="plain">
+<replaceable class="parameter">feature</replaceable>
+<replaceable class="parameter">command</replaceable>
+</arg>
+</group>
+</cmdsynopsis>
+
+<para>
+This command allows to test if a <quote>feature</quote> has been
+compiled in, before actually executing the <quote>command</quote>.
+<quote>feature</quote> can be either the name of a function or
+a variable.
+</para>
+
+<para>
+Example:
+<quote>
+ifdef imap_keepalive 'source ~/.mutt/imap_setup'
+</quote>
+</para>
+
+</sect1>
+
<sect1 id="unhook">
<title>Removing Hooks</title>
<para>Usage:</para>
Index: mutt-1.5.21/init.c
===================================================================
--- mutt-1.5.21.orig/init.c
+++ mutt-1.5.21/init.c
@@ -604,8 +604,54 @@ static void remove_from_list (LIST **l,
}
}
}
+static int parse_ifdef (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err)
+{
+ int i, j, res = 0;
+ BUFFER token;
+
+ memset (&token, 0, sizeof (token));
+ mutt_extract_token (tmp, s, 0);
+
+ /* is the item defined as a variable or a function? */
+ if (!(res = (mutt_option_index (tmp->data) != -1)))
+ for (i = 0; !res && i < MENU_MAX; i++)
+ {
+ struct binding_t *b = km_get_table (Menus[i].value);
+
+ if (!b)
+ continue;
+
+ for (j = 0; b[j].name; j++)
+ if (!ascii_strncasecmp (tmp->data, b[j].name, mutt_strlen (tmp->data))
+ && (mutt_strlen (b[j].name) == mutt_strlen (tmp->data)))
+ {
+ res = 1;
+ break;
+ }
+ }
+
+ if (!MoreArgs (s))
+ {
+ snprintf (err->data, err->dsize, _("ifdef: too few arguments"));
+ return (-1);
+ }
+ mutt_extract_token (tmp, s, M_TOKEN_SPACE);
+
+ if (res)
+ {
+ if (mutt_parse_rc_line (tmp->data, &token, err) == -1)
+ {
+ mutt_error ("Erreur: %s", err->data);
+ FREE (&token.data);
+ return (-1);
+ }
+ FREE (&token.data);
+ }
+ return 0;
+}
+
static int parse_unignore (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
{
do
{
Index: mutt-1.5.21/init.h
===================================================================
--- mutt-1.5.21.orig/init.h
+++ mutt-1.5.21/init.h
@@ -3565,8 +3565,9 @@ static int parse_group (BUFFER *, BUFFER
static int parse_lists (BUFFER *, BUFFER *, unsigned long, BUFFER *);
static int parse_unlists (BUFFER *, BUFFER *, unsigned long, BUFFER *);
static int parse_alias (BUFFER *, BUFFER *, unsigned long, BUFFER *);
static int parse_unalias (BUFFER *, BUFFER *, unsigned long, BUFFER *);
+static int parse_ifdef (BUFFER *, BUFFER *, unsigned long, BUFFER *);
static int parse_ignore (BUFFER *, BUFFER *, unsigned long, BUFFER *);
static int parse_unignore (BUFFER *, BUFFER *, unsigned long, BUFFER *);
static int parse_source (BUFFER *, BUFFER *, unsigned long, BUFFER *);
static int parse_set (BUFFER *, BUFFER *, unsigned long, BUFFER *);
@@ -3621,8 +3622,9 @@ struct command_t Commands[] = {
{ "group", parse_group, M_GROUP },
{ "ungroup", parse_group, M_UNGROUP },
{ "hdr_order", parse_list, UL &HeaderOrderList },
#ifdef HAVE_ICONV
+ { "ifdef", parse_ifdef, 0 },
{ "iconv-hook", mutt_parse_hook, M_ICONVHOOK },
#endif
{ "ignore", parse_ignore, 0 },
{ "lists", parse_lists, 0 },
Index: mutt-1.5.21/PATCHES
===================================================================
--- mutt-1.5.21.orig/PATCHES
+++ mutt-1.5.21/PATCHES
@@ -1,5 +1,6 @@
patch-1.5.3.vk.pgp_verbose_mime
+patch-1.5.4.cd.ifdef.1
patch-1.5.5.1.cd.signatures_menu.2.1
patch-1.5.5.1.cd.purge_message.3.4
patch-1.5.5.1.cd.trash_folder.3.4
patch-1.5.9.aw.listreply.1