Rocco Rutte:
authorpdmef <pdmef@e385b8ad-14ed-0310-8656-cc95a2468c6d>
Thu, 10 Mar 2005 15:53:04 +0000 (15:53 +0000)
committerpdmef <pdmef@e385b8ad-14ed-0310-8656-cc95a2468c6d>
Thu, 10 Mar 2005 15:53:04 +0000 (15:53 +0000)
included CD's ifdef patch

git-svn-id: svn://svn.berlios.de/mutt-ng/trunk@165 e385b8ad-14ed-0310-8656-cc95a2468c6d

ChangeLog.mutt-ng
PATCHES
UPGRADING
doc/manual.sgml.head
init.c
init.h

index 6d0c9c9..3f2e302 100644 (file)
@@ -1,5 +1,8 @@
 Changes specific to mutt-ng:
 
+2005-03-10:
+  * included CD's ifdef patch
+
 2005-03-05:
   * added color sidebar
 
diff --git a/PATCHES b/PATCHES
index 20de3c3..5a1a985 100644 (file)
--- a/PATCHES
+++ b/PATCHES
@@ -4,12 +4,13 @@ patch-1.5.5.1.pdmef.short_mbox_name.1
 rr.compressed
 patch-1.5.4.fw.maildir_inode_sort
 patch-1.4.admcd.gnutls.59d
-patch-1.5.5.1.cd.edit_threads.9.5
 patch-1.5.6i.sidebar.20041122
 patch-1.5.4.aw.listreply.1
-patch-1.5.4.cd.source_multiple.2
 vvv.initials
 patch-1.5.5.1.cd.purge_message.3.4
 patch-1.5.5.1.cd.trash_folder.3.4
+patch-1.5.5.1.cd.edit_threads.9.5
+patch-1.5.4.cd.ifdef.1
+patch-1.5.4.cd.source_multiple.2
 vvv.quote
 vvv.nntp
index 1ed2f73..c2cc7d5 100644 (file)
--- a/UPGRADING
+++ b/UPGRADING
@@ -14,6 +14,11 @@ Note: as development goes fast and as documentation is way behind it,
 this still likely is incomplete. Please report missing items to
 <mutt-ng-devel@lists.berlios.de>
 
+2005-03-10
+
+  New Configuration Command (from CD's ifdef Patch):
+    - ifdef
+
 2005-03-07
 
   New Variables: 
index a8f069b..f07f026 100644 (file)
@@ -1709,6 +1709,19 @@ If the filename ends with a vertical bar (|), then <em/filename/ is
 considered to be an executable program from which to read input (eg.
 <tt>source ~/bin/myscript|</tt>).
 
+<sect1>Configuring features conditionnaly<label id="ifdef">
+<p>
+Usage: <tt/ifdef/ <em/item/ <em/command/
+
+This command allows to test if a feature has been compiled in, before
+actually executing the command. Item can be either the name of a
+function or a variable.
+
+Example:
+<tscreen><verb>
+ifdef imap_keepalive 'source ~/.mutt/imap_setup'
+</verb></tscreen>
+
 <sect1>Removing hooks<label id="unhook">
 <p>
 Usage: <tt/unhook/ &lsqb; * | <em/hook-type/ &rsqb;
diff --git a/init.c b/init.c
index 29f67fb..9c81fe1 100644 (file)
--- a/init.c
+++ b/init.c
@@ -542,6 +542,52 @@ static int remove_from_rx_list (RX_LIST **l, const char *str)
   return (rv);
 }
 
+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
diff --git a/init.h b/init.h
index 0a2afdc..e1bf9f1 100644 (file)
--- a/init.h
+++ b/init.h
@@ -3525,6 +3525,7 @@ 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 *);
@@ -3571,6 +3572,7 @@ struct command_t Commands[] = {
 #endif
   { "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 },