Changes specific to mutt-ng:
2005-03-10:
- * included CD's ifdef patch
+ * included CD's ifdef patch plus extension ('ifndef', feature_*), see manual
2005-03-05:
* added color sidebar
2005-03-10
- New Configuration Command (from CD's ifdef Patch):
+ New Configuration Command (based on CD's ifdef Patch):
- ifdef
+ - ifndef
2005-03-07
considered to be an executable program from which to read input (eg.
<tt>source ~/bin/myscript|</tt>).
-<sect1>Configuring features conditionnaly<label id="ifdef">
+<sect1>Configuring features conditionaly<label id="ifdef">
<p>
Usage: <tt/ifdef/ <em/item/ <em/command/
+Usage: <tt/ifndef/ <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.
+These command allows to test if a variable, function or certain feature
+is available or not respectively, before actually executing the command.
+<tt/ifdef/ (short for ``if defined) handles commands if upon
+availability while <tt/ifndef/ (short for ``if not defined'') does if
+not. The <em/command/ may be any valid fraction of a configuration file.
-Example:
+All names of variables and functions may be tested. Additionally, the
+following compile-features may be tested when prefixed with 'feature_':
+ncurses, slang, iconv, idn, dotlock, standalone, pop, nntp, imap, ssl,
+gnutls, sasl, sasl2, libesmtp, compressed, color, classic_pgp,
+classic_smime, gpgme, header_cache.
+
+Examples follow.
+
+To only source a file with IMAP related settings only if IMAP support is
+compiled in, use:
<tscreen><verb>
-ifdef imap_keepalive 'source ~/.mutt/imap_setup'
+ifdef feature_imap 'source ~/.mutt-ng/imap_setup'
+# or
+# ifdef imap_user 'source ~/.mutt-ng/imap_setup'
+# or
+# ...
</verb></tscreen>
+To exit mutt-ng directly if no NNTP support is compiled in:
+<tscreen><verb>
+ifndef feature_nntp 'push q'
+# or
+# ifndef newsrc 'push q'
+# or
+# ...
+</verb/</tscreen>
+
+To only set the <ref id="imap_mail_check"
+name="<$imap_mail_check"> when the system's SVN
+is recent enough to have it:
+<tscreen><verb>
+ifdef imap_mail_check 'set imap_mail_check=300'
+</tscreen></verb>
+
<sect1>Removing hooks<label id="unhook">
<p>
Usage: <tt/unhook/ [ * | <em/hook-type/ ]
break;
}
}
+ /* check for feature_* */
+ if (!res) {
+ char* p = NULL;
+ i = 0;
+ j = mutt_strlen (tmp->data);
+ /* need at least input of 'feature_X' */
+ if (j >= 7) {
+ p = tmp->data + 7;
+ j -= 7;
+ while (Features[i].name) {
+ if (mutt_strlen (Features[i].name) == j &&
+ ascii_strncasecmp (Features[i].name, p, j)) {
+ res = 1;
+ break;
+ }
+ i++;
+ }
+ }
+ }
if (!MoreArgs (s))
{
- snprintf (err->data, err->dsize, _("ifdef: too few arguments"));
+ if (data)
+ snprintf (err->data, err->dsize, _("ifdef: too few arguments"));
+ else
+ snprintf (err->data, err->dsize, _("ifndef: too few arguments"));
return (-1);
}
mutt_extract_token (tmp, s, M_TOKEN_SPACE);
- if (res)
+ if ((data && res) || (!data && !res))
{
if (mutt_parse_rc_line (tmp->data, &token, err) == -1)
{
- mutt_error ("Erreur: %s", err->data);
+ mutt_error ("Error: %s", err->data);
FREE (&token.data);
return (-1);
}
unsigned long init; /* initial value */
};
+struct feature_t
+{
+ char* name;
+ short builtin;
+};
+
#define UL (unsigned long)
#endif /* _MAKEDOC */
{ NULL }
};
+const struct feature_t Features[] = {
+ { "ncurses",
+#ifdef NCURSES_VERSION
+ 1
+#else
+ 0
+#endif
+ }, { "slang",
+#ifdef USE_SLANG_CURSES
+ 1
+#else
+ 0
+#endif
+ }, { "iconv",
+#ifdef _LIBICONV_VERSION
+ 1
+#else
+ 0
+#endif
+ }, { "idn",
+#ifdef HAVE_LIBIDN
+ 1
+#else
+ 0
+#endif
+ }, { "dotlock",
+#ifdef USE_DOTLOCK
+ 1
+#else
+ 0
+#endif
+ }, { "standalone",
+#ifdef DL_STANDALONE
+ 1
+#else
+ 0
+#endif
+ }, { "pop",
+#ifdef USE_POP
+ 1
+#else
+ 0
+#endif
+ }, { "nntp",
+#ifdef USE_NNTP
+ 1
+#else
+ 0
+#endif
+ }, { "imap",
+#ifdef USE_IMAP
+ 1
+#else
+ 0
+#endif
+ }, { "ssl",
+#ifdef USE_SSL
+ 1
+#else
+ 0
+#endif
+ }, { "gnutls",
+#ifdef USE_GNUTLS
+ 1
+#else
+ 0
+#endif
+ }, { "sasl",
+#ifdef USE_SASL
+ 1
+#else
+ 0
+#endif
+ }, { "sasl2",
+#ifdef USE_SASL2
+ 1
+#else
+ 0
+#endif
+ }, { "libesmtp",
+#ifdef USE_LIBESMTP
+ 1
+#else
+ 0
+#endif
+ }, { "compressed",
+#ifdef USE_COMPRESSED
+ 1
+#else
+ 0
+#endif
+ }, { "color",
+#ifdef HAVE_COLOR
+ 1
+#else
+ 0
+#endif
+ }, { "classic_pgp",
+#ifdef CRYPT_BACKEND_CLASSIC_PGP
+ 1
+#else
+ 0
+#endif
+ }, { "classic_smime",
+#ifdef CRYPT_BACKEND_CLASSIC_SMIME
+ 1
+#else
+ 0
+#endif
+ }, { "gpgme",
+#ifdef CRYPT_BACKEND_GPGME
+ 1
+#else
+ 0
+#endif
+ }, { "header_cache",
+#ifdef USE_HCACHE
+ 1
+#else
+ 0
+#endif
+ },
+ /* last */
+ { NULL, 0 }
+};
+
const struct mapping_t SortMethods[] = {
{ "date", SORT_DATE },
{ "date-sent", SORT_DATE },
{ "append-hook", mutt_parse_hook, M_APPENDHOOK },
#endif
{ "hdr_order", parse_list, UL &HeaderOrderList },
+ { "ifdef", parse_ifdef, 1 },
+ { "ifndef", parse_ifdef, 0 },
#ifdef HAVE_ICONV
- { "ifdef", parse_ifdef, 0 },
{ "iconv-hook", mutt_parse_hook, M_ICONVHOOK },
#endif
{ "ignore", parse_ignore, 0 },