updated on Wed Jan 25 12:16:47 UTC 2012
[aur-mirror.git] / mutt-great-dane / patch-1.5.21.cd.ifdef.2
blob8d424945612d3fa4ca77801365e1e3f778446f2f
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
4 @@ -0,0 +1 @@
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
9 @@ -4103,6 +4103,30 @@
11  </sect1>
13 +<sect1 id="ifdef">
14 +<title>Configuring features conditionnaly</title>
16 +<cmdsynopsis>
17 +<command>ifdef</command>
18 +<group choice="req">
19 +<arg choice="plain">
20 +<replaceable class="parameter">item</replaceable>
21 +</arg>
22 +<arg choice="plain">
23 +<replaceable class="parameter">command</replaceable>
24 +</arg>
25 +</group>
26 +</cmdsynopsis>
28 +<para>
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 &tilde;/.mutt/imap_setup'</literal>
34 +</para>
35 +</sect1>
37  <sect1 id="unhook">
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
43 @@ -635,6 +635,52 @@
44    return (rv);
45  }
47 +static int parse_ifdef (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err)
49 +  int i, j, res = 0;
50 +  BUFFER token;
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++)
58 +    {
59 +      struct binding_t *b = km_get_table (Menus[i].value);
61 +      if (!b)
62 +       continue;
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)))
67 +       {
68 +         res = 1;
69 +         break;
70 +       }
71 +    }
73 +  if (!MoreArgs (s))
74 +  {
75 +    snprintf (err->data, err->dsize, _("ifdef: too few arguments"));
76 +    return (-1);
77 +  }
78 +  mutt_extract_token (tmp, s, M_TOKEN_SPACE);
80 +  if (res)
81 +  {
82 +    if (mutt_parse_rc_line (tmp->data, &token, err) == -1)
83 +    {
84 +      mutt_error ("Erreur: %s", err->data);
85 +      FREE (&token.data);
86 +      return (-1);
87 +    }
88 +    FREE (&token.data);
89 +  }
90 +  return 0;
93  static int parse_unignore (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
94  {
95    do
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
99 @@ -3664,6 +3664,7 @@
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 },
112  #ifdef HAVE_ICONV
113    { "iconv-hook",      mutt_parse_hook,        M_ICONVHOOK },
114  #endif