ADDRESS -> address_t
[apps/madmutt.git] / init.h
diff --git a/init.h b/init.h
index 3afe5f1..1d93b5a 100644 (file)
--- a/init.h
+++ b/init.h
 #define R_RESORT_BOTH   (R_RESORT|R_RESORT_SUB)
 
 struct option_t {
-  char *option;
+  const char *option;
   short type;
   short flags;
   unsigned long data;
-  char* init;
+  const char *init;
 };
 
 #define UL (unsigned long)
@@ -279,10 +279,12 @@ struct option_t MuttVars[] = {
    ** .dt %m  .dd major MIME type
    ** .dt %M  .dd MIME subtype
    ** .dt %n  .dd attachment number
+   ** .dt %Q  .dd "Q", if MIME part qualifies for attachment counting
    ** .dt %s  .dd size
    ** .dt %t  .dd tagged flag
    ** .dt %T  .dd graphic tree characters
    ** .dt %u  .dd unlink (=to delete) flag
+   ** .dt %X  .dd number of qualifying MIME parts in this part and its children
    ** .dt %>X .dd right justify the rest of the string and pad with character "X"
    ** .dt %|X .dd pad to the end of the line with character "X"
    ** .de
@@ -407,6 +409,18 @@ struct option_t MuttVars[] = {
    ** When \fIunset\fP, Mutt-ng will not collapse a thread if it contains any
    ** unread messages.
    */
+  {"count_attachments", DT_BOOL, R_NONE, OPTCOUNTATTACH, "yes"},
+  /*
+   ** .pp
+   ** This variable controls whether attachments should be counted for $$$index_format
+   ** and its \fT%X\fP expando or not. As for scoring, this variable can be used to
+   ** selectively turn counting on or off instead of removing and re-adding rules as
+   ** prefered because counting requires full loading of messages.
+   ** .pp
+   ** If it is \fIset\fP and rules were defined via the \fTattachments\fP and/or
+   ** \fTunattachments\fP commands, counting will be done. If it is \fIunset\fP no
+   ** counting will be done regardless whether rules were defined or not.
+   */
   {"uncollapse_jump", DT_BOOL, R_NONE, OPTUNCOLLAPSEJUMP, "no" },
   /*
    ** .pp
@@ -625,7 +639,7 @@ struct option_t MuttVars[] = {
   /*
    ** .pp
    ** This variable controls whether Mutt-ng, when sorting by threads, threads
-   ** messages with the same \fTMessage-Id:\fP header field together.
+   ** messages with the same \fTMessage-ID:\fP header field together.
    ** If it is \fIset\fP, it will indicate that it thinks they are duplicates
    ** of each other with an equals sign in the thread diagram.
    */
@@ -670,7 +684,7 @@ struct option_t MuttVars[] = {
    ** delivery and transport agents tend to do with messages.
    **
    ** .pp
-   ** \fBNote:\fP as mutt-ng currently violates RfC3676 defining
+   ** \fBNote:\fP as Mutt-ng currently violates RfC3676 defining
    ** \fTformat=flowed\fP, it's <em/strongly/ advised to \fIset\fP
    ** this option although discouraged by the standard. Alternatively,
    ** you must take care of space-stuffing <tt/From / lines (with a trailing
@@ -680,7 +694,7 @@ struct option_t MuttVars[] = {
   {"use_envelope_from", DT_BOOL, R_NONE, OPTENVFROM, "no" },
   /*
    ** .pp
-   ** When \fIset\fP, mutt-ng will use ``$$envelope_from_address'' as the
+   ** When \fIset\fP, Mutt-ng will use ``$$envelope_from_address'' as the
    ** \fIenvelope\fP sender if that is set, otherwise it will attempt to
    ** derive it from the "From:" header.
    **
@@ -691,6 +705,7 @@ struct option_t MuttVars[] = {
    */
   {"envelope_from_address", DT_ADDR, R_NONE, UL &EnvFrom, "" },
   /*
+  ** .pp
   ** Manually sets the \fIenvelope\fP sender for outgoing messages.
   ** This value is ignored if ``$$use_envelope_from'' is unset.
   */
@@ -859,7 +874,7 @@ struct option_t MuttVars[] = {
    ** .pp
    ** E.g. you can use 
    ** \fTsend-hook Mutt-ng-devel@lists.berlios.de 'my_hdr From: Foo Bar <foo@bar.fb>'\fP
-   ** when replying to the mutt-ng developer's mailing list and Mutt-ng takes this email address.
+   ** when replying to the Mutt-ng developer's mailing list and Mutt-ng takes this email address.
    ** .pp
    ** Defaults to the contents of the environment variable \fT$$$EMAIL\fP.
    */
@@ -987,7 +1002,7 @@ struct option_t MuttVars[] = {
   /*
    ** .pp
    ** Specifies the hostname to use after the ``\fT@\fP'' in local e-mail
-   ** addresses and during generation of \fTMessage-Id:\fP headers.
+   ** addresses and during generation of \fTMessage-ID:\fP headers.
    ** .pp
    ** Please be sure to really know what you are doing when changing this variable
    ** to configure a custom domain part of Message-IDs.
@@ -1003,6 +1018,8 @@ struct option_t MuttVars[] = {
    ** mailing list when this option is set, use the \fIlist-reply\fP
    ** function; \fIgroup-reply\fP will reply to both the sender and the
    ** list.
+   ** Remember: This option works only for mailing lists which are explicitly set in your muttngrc
+   ** configuration file.
    */
 #ifdef USE_IMAP
   {"imap_authenticators", DT_STR, R_NONE, UL &ImapAuthenticators, "" },
@@ -1257,6 +1274,7 @@ struct option_t MuttVars[] = {
    ** .dt %u .dd user (login) name of the author
    ** .dt %v .dd first name of the author, or the recipient if the message is from you
    ** .dt %W .dd name of organization of author (`organization:' field)
+   ** .dt %X .dd number of attachments
    ** .dt %y .dd `x-label:' field, if present
    ** .dt %Y .dd `x-label' field, if present, and (1) not at part of a thread tree,
    **            (2) at the top of a thread, or (3) `x-label' is different from
@@ -1315,12 +1333,12 @@ struct option_t MuttVars[] = {
    ** The locale used by \fTstrftime(3)\fP to format dates. Legal values are
    ** the strings your system accepts for the locale variable \fTLC_TIME\fP.
    */
-  {"list_reply", DT_QUAD, R_NONE, OPT_LISTREPLY, "no" },
+  {"force_list_reply", DT_QUAD, R_NONE, OPT_LISTREPLY, "ask-no" },
   /*
    ** .pp
-   ** When \fIset\fP, address replies to the mailing list the original message came
-   ** from (instead to the author only). Setting this option to ``\fIask-yes\fP'' or
-   ** ``\fIask-no\fP'' will ask if you really intended to reply to the author only.
+   ** This variable controls what effect ordinary replies have on mailing list
+   ** messages: if \fIset\fP, a normal reply will be interpreted as list-reply
+   ** while if it's \fIunset\fP the reply functions work as usual.
    */
   {"max_display_recips", DT_NUM, R_PAGER, UL &MaxDispRecips, "0" },
   /*
@@ -1484,7 +1502,7 @@ struct option_t MuttVars[] = {
    ** \fIThis is a read-only system property and specifies the
    ** directory containing the muttng documentation.\fP
    */
-#if USE_HCACHE
+#ifdef USE_HCACHE
 #if HAVE_QDBM
   {"muttng_hcache_backend", DT_SYS, R_NONE, 0, "qdbm" },
 #elif HAVE_GDBM
@@ -1511,9 +1529,20 @@ struct option_t MuttVars[] = {
   /*
    ** .pp
    ** \fIThis is a read-only system property and, at runtime,
-   ** specifies the last part of the full path or URI of the
-   ** folder currently open (if any), i.e. everything after
-   ** the last ``/''.\fP
+   ** specifies the actual name of the folder as far as it could
+   ** be detected.\fP
+   ** .pp
+   ** For detection, $$$folder is first taken into account
+   ** and simply stripped to form the result when a match is found. For
+   ** example, with $$$folder being \fTimap://host\fP and the folder is
+   ** \fTimap://host/INBOX/foo\fP, $$$muttng_folder_name will be just
+   ** \fTINBOX/foo\fP.)
+   ** .pp
+   ** Second, if the initial portion of a name is not $$$folder,
+   ** the result will be everything after the last ``/''.
+   ** .pp
+   ** Third and last, the result will be just the name if neither
+   ** $$$folder nor a ``/'' were found in the name.
    */
   {"muttng_pwd", DT_SYS, R_NONE, 0, "" },
   /*
@@ -1565,7 +1594,7 @@ struct option_t MuttVars[] = {
    ** .pp
    ** This variable controls how message counts are printed when the sidebar
    ** is enabled. If this variable is \fIempty\fP (\fIand only if\fP), no numbers
-   ** will be printed \fIand\fP mutt-ng won't frequently count mail (which
+   ** will be printed \fIand\fP Mutt-ng won't frequently count mail (which
    ** may be a great speedup esp. with mbox-style mailboxes.)
    ** .pp
    ** The following \fTprintf(3)\fP-like sequences are supported all of which
@@ -1578,6 +1607,7 @@ struct option_t MuttVars[] = {
    ** .dt %M .dd Total number of messages shown, i.e. not hidden by a limit. 1)
    ** .dt %n .dd Number of new messages.
    ** .dt %t .dd Number of tagged messages. 1)
+   ** .dt %u .dd Number of unread messages.
    ** .de
    ** .pp
    ** 1) These expandos only have a non-zero value for the current mailbox and
@@ -1635,9 +1665,9 @@ struct option_t MuttVars[] = {
    ** If \fIset\fP, forces Mutt-ng to interpret keystrokes with the high bit (bit 8)
    ** set as if the user had pressed the \fTESC\fP key and whatever key remains
    ** after having the high bit removed.  For example, if the key pressed
-   ** has an ASCII value of \fT0xf4\fP, then this is treated as if the user had
+   ** has an ASCII value of \fT0xf8\fP, then this is treated as if the user had
    ** pressed \fTESC\fP then ``\fTx\fP''.  This is because the result of removing the
-   ** high bit from ``\fT0xf4\fP'' is ``\fT0x74\fP'', which is the ASCII character
+   ** high bit from ``\fT0xf8\fP'' is ``\fT0x78\fP'', which is the ASCII character
    ** ``\fTx\fP''.
    */
   {"mh_purge", DT_BOOL, R_NONE, OPTMHPURGE, "no" },
@@ -1753,8 +1783,8 @@ struct option_t MuttVars[] = {
   {"msgid_format", DT_STR, R_NONE, UL &MsgIdFormat, "%Y%m%d%h%M%s.G%P%p"},
   /*
    ** .pp
-   ** This is the format for the ``local part'' of the \fTMessage-Id:\fP header
-   ** field generated by Mutt-ng. If this variable is empty, no \fTMessage-Id:\fP
+   ** This is the format for the ``local part'' of the \fTMessage-ID:\fP header
+   ** field generated by Mutt-ng. If this variable is empty, no \fTMessage-ID:\fP
    ** headers will be generated. The '%'
    ** character marks that certain data will be added to the string, similar to
    ** \fTprintf(3)\fP. The following characters are allowed:
@@ -2591,7 +2621,7 @@ struct option_t MuttVars[] = {
   {"ssl_force_tls", DT_BOOL, R_NONE, OPTSSLFORCETLS, "no" },
   /*
    ** .pp
-   ** If this variable is \fIset\fP, mutt-ng will require that all connections
+   ** If this variable is \fIset\fP, Mutt-ng will require that all connections
    ** to remote servers be encrypted. Furthermore it will attempt to
    ** negotiate TLS even if the server does not advertise the capability,
    ** since it would otherwise have to abort the connection anyway. This
@@ -2645,7 +2675,7 @@ struct option_t MuttVars[] = {
    ** The file which includes random data that is used to initialize SSL
    ** library functions.
    */
-  {"ssl_use_sslv2", DT_BOOL, R_NONE, OPTSSLV2, "yes" },
+  {"ssl_use_sslv2", DT_BOOL, R_NONE, OPTSSLV2, "no" },
   /*
    ** .pp
    ** Availability: SSL
@@ -2756,7 +2786,7 @@ struct option_t MuttVars[] = {
    ** Availability: POP
    **
    ** .pp
-   ** This variable configures how often (in seconds) POP should look for
+   ** This variable configures how often (in seconds) Mutt-ng should look for
    ** new mail.
    */
   {"pop_delete", DT_QUAD, R_NONE, OPT_POPDELETE, "ask-no" },
@@ -2800,7 +2830,7 @@ struct option_t MuttVars[] = {
    ** Availability: POP
    **
    ** .pp
-   ** Controls whether or not Mutt-ng will try to reconnect to a POP server when the
+   ** Controls whether or not Mutt-ng will try to reconnect to a POP server if the
    ** connection is lost.
    */
   {"pop_user", DT_STR, R_NONE, UL &PopUser, "" },
@@ -3516,7 +3546,7 @@ struct option_t MuttVars[] = {
    ** if ``$$edit_headers'' is unset.
    **
    ** .pp
-   ** If this variable is \fIset\fP, mutt-ng is strict and allows anything to be
+   ** If this variable is \fIset\fP, Mutt-ng is strict and allows anything to be
    ** changed. If it's \fIunset\fP, all headers given will be prefixed with
    ** ``X-Mailto-'' and the message including headers will be shown in the editor
    ** regardless of what ``$$edit_headers'' is set to.
@@ -3549,14 +3579,14 @@ struct option_t MuttVars[] = {
   {"strip_was", DT_BOOL, R_NONE, OPTSTRIPWAS, "no" },
   /**
   ** .pp
-  ** When \fIset\fP, mutt-ng will remove the trailing part of the ``\fTSubject:\fP''
+  ** When \fIset\fP, Mutt-ng will remove the trailing part of the ``\fTSubject:\fP''
   ** line which matches $$strip_was_regex when replying. This is useful to
   ** properly react on subject changes and reduce ``subject noise.'' (esp. in Usenet)
   **/
   {"strip_was_regex", DT_RX, R_NONE, UL &StripWasRegexp, "\\([Ww][Aa][RrSs]: .*\\)[ ]*$"},
   /**
   ** .pp
-  ** When non-empty and $$strip_was is \fIset\fP, mutt-ng will remove this
+  ** When non-empty and $$strip_was is \fIset\fP, Mutt-ng will remove this
   ** trailing part of the ``Subject'' line when replying if it won't be empty
   ** afterwards.
   **/
@@ -3794,8 +3824,8 @@ struct option_t MuttVars[] = {
   /*
    ** .pp
    ** If $$xterm_set_titles is \fIset\fP, this string will be used to
-   ** set the title when leaving mutt-ng. For terminal-based programs,
-   ** there's no easy and portable way to read the current title so mutt-ng
+   ** set the title when leaving Mutt-ng. For terminal-based programs,
+   ** there's no easy and portable way to read the current title so Mutt-ng
    ** cannot read it upon startup and restore it when exiting.
    **
    ** .pp
@@ -3824,7 +3854,7 @@ struct option_t MuttVars[] = {
    */
 #endif
   /*--*/
-  { NULL }
+  { NULL, -1, R_NONE, -1, NULL }
 };
 
 static const char* Features[] = {
@@ -3938,14 +3968,14 @@ const struct mapping_t SortBrowserMethods[] = {
   {"date", SORT_DATE},
   {"size", SORT_SIZE},
   {"unsorted", SORT_ORDER},
-  {NULL}
+  {NULL, 0}
 };
 
 const struct mapping_t SortAliasMethods[] = {
   {"alias", SORT_ALIAS},
   {"address", SORT_ADDRESS},
   {"unsorted", SORT_ORDER},
-  {NULL}
+  {NULL, 0}
 };
 
 const struct mapping_t SortKeyMethods[] = {
@@ -3953,7 +3983,7 @@ const struct mapping_t SortKeyMethods[] = {
   {"date", SORT_DATE},
   {"keyid", SORT_KEYID},
   {"trust", SORT_TRUST},
-  {NULL}
+  {NULL, 0}
 };
 
 
@@ -3962,7 +3992,8 @@ const struct mapping_t SortKeyMethods[] = {
 static int parse_list (BUFFER *, BUFFER *, unsigned long, BUFFER *);
 static int parse_spam_list (BUFFER *, BUFFER *, unsigned long, BUFFER *);
 static int parse_unlist (BUFFER *, BUFFER *, unsigned long, BUFFER *);
-
+static int parse_attachments (BUFFER *, BUFFER *, unsigned long, BUFFER *);
+static int parse_unattachments (BUFFER *, BUFFER *, unsigned long, 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 *);
@@ -3981,14 +4012,15 @@ static int parse_alternates (BUFFER *, BUFFER *, unsigned long, BUFFER *);
 static int parse_unalternates (BUFFER *, BUFFER *, unsigned long, BUFFER *);
 
 struct command_t {
-  char *name;
+  const char *name;
   int (*func) (BUFFER *, BUFFER *, unsigned long, BUFFER *);
   unsigned long data;
-  unsigned long data1;
 };
 
 struct command_t Commands[] = {
   {"alternates", parse_alternates, 0},
+  {"attachments", parse_attachments, 0 },
+  {"unattachments",parse_unattachments,0 },
   {"unalternates", parse_unalternates, 0},
 #ifdef USE_SOCKET
   {"account-hook", mutt_parse_hook, M_ACCOUNTHOOK},
@@ -4055,5 +4087,5 @@ struct command_t Commands[] = {
   {"unscore", mutt_parse_unscore, 0},
   {"unset", parse_set, M_SET_UNSET},
   {"unsubscribe", parse_unsubscribe, 0},
-  {NULL}
+  {NULL, NULL, 0}
 };