--- a/OPS Tue Oct 4 19:00:05 2005 +++ b/OPS Wed Oct 5 18:36:54 2005 @@ -158,6 +158,7 @@ OP_SHELL_ESCAPE "invoke a command in a subshell" OP_SORT "sort messages" OP_SORT_REVERSE "sort messages in reverse order" +OP_STATUS_COMMANDS "show status of most of the commands" OP_TAG "tag the current entry" OP_TAG_PREFIX "apply next function to tagged messages" OP_TAG_PREFIX_COND "apply next function ONLY to tagged messages" --- a/curs_main.c Tue Oct 4 19:00:05 2005 +++ b/curs_main.c Wed Oct 5 18:36:54 2005 @@ -826,6 +826,14 @@ case OP_HELP: mutt_help (MENU_MAIN); + menu->redraw = REDRAW_FULL; + break; + + case OP_STATUS_COMMANDS: + + InComval = 1; + mutt_comval (); + InComval = 0; menu->redraw = REDRAW_FULL; break; --- a/functions.h Tue Oct 4 19:00:05 2005 +++ b/functions.h Wed Oct 5 18:36:54 2005 @@ -50,6 +50,7 @@ { "half-up", OP_HALF_UP, "[" }, { "half-down", OP_HALF_DOWN, "]" }, { "help", OP_HELP, "?" }, + { "status-commands", OP_STATUS_COMMANDS, NULL }, { "tag-prefix", OP_TAG_PREFIX, ";" }, { "tag-prefix-cond", OP_TAG_PREFIX_COND, NULL }, { "end-cond", OP_END_COND, NULL }, @@ -213,6 +214,7 @@ OP_MAIN_NEXT_NEW_THEN_UNREAD, "\t" }, { "pipe-message", OP_PIPE, "|" }, { "help", OP_HELP, "?" }, + { "status-commands", OP_STATUS_COMMANDS, NULL }, { "next-page", OP_NEXT_PAGE, " " }, { "previous-page", OP_PREV_PAGE, "-" }, { "top", OP_PAGER_TOP, "^" }, --- a/globals.h Tue Oct 4 19:00:05 2005 +++ b/globals.h Wed Oct 5 18:36:54 2005 @@ -176,6 +177,7 @@ WHERE short ConnectTimeout; WHERE short HistSize; +WHERE short InComval INITVAL (0); WHERE short MenuContext; WHERE short PagerContext; WHERE short PagerIndexLines; --- a/help.c Tue Oct 4 19:00:05 2005 +++ b/help.c Wed Oct 5 18:36:54 2005 @@ -353,3 +353,46 @@ NULL) == OP_REFORMAT_WINCH); } + +void mutt_comval () +{ + char t[_POSIX_PATH_MAX]; + FILE *f; + BUFFER *comval; + + mutt_mktemp (t); + + do { + if ((f = safe_fopen (t, "w")) == NULL) + { + mutt_perror (t); + return; + } + + comval = NULL; + + comval = mutt_buffer_init (comval); + fputs (_("Status of commands:\n\n"), f); + if (!mutt_dump_command_values (comval, 0)) + fputs (comval->data, f); + else + fputs (_("unknown error"), f); + mutt_buffer_free (&comval); + + comval = mutt_buffer_init (comval); + fputs (_("\nUnused commands:\n\n"), f); + if (!mutt_dump_command_values (comval, 1)) + fputs (comval->data, f); + else + fputs (_("unknown error"), f); + mutt_buffer_free (&comval); + + fclose (f); + } + while + (mutt_do_pager (_("Status of commands"), t, + M_PAGER_RETWINCH | M_PAGER_MARKER | M_PAGER_NSKIP, + NULL) + == OP_REFORMAT_WINCH); +} + --- a/hook.c Tue Oct 4 19:00:05 2005 +++ b/hook.c Wed Oct 5 18:36:54 2005 @@ -485,3 +485,29 @@ FREE (&token.data); } #endif + +int mutt_dump_hook (BUFFER *buf, unsigned long type) +{ + HOOK *h; + char s[STRING]; + int match = 0; + if (!buf) + return 1; + for (h = Hooks; h; h = h->next) + { + if (h->type & type) + { + match = 1; + mutt_buffer_addstr (buf, h->rx.not ? "\n !( " : "\n "); + mutt_format_string (s, sizeof (s), 0, sizeof (s), 0, + 0, h->rx.pattern, sizeof (s), 0); + mutt_buffer_addstr (buf, s); + mutt_buffer_addstr (buf, h->rx.not ? " )\n " : "\n "); + mutt_format_string (s, sizeof (s), 0, sizeof (s), 0, + 0, h->command, sizeof (s), 0); + mutt_buffer_addstr (buf, s); + } + } + return (match) ? 0 : -1; +} + --- a/init.c Tue Oct 4 19:00:05 2005 +++ b/init.c Wed Oct 5 18:36:54 2005 @@ -531,6 +531,40 @@ return nremoved; } +static int dump_spam_list (BUFFER *buf) +{ + SPAM_LIST *old, *spam; + char s[STRING]; + if (!buf) + return 1; + for (old = spam = SpamList; spam; spam = spam->next) + { + if (!spam->rx || !spam->template) + return 1; + mutt_buffer_addstr (buf, "\n "); + if (spam->rx->not) + mutt_buffer_addstr (buf, "!( "); + mutt_format_string (s, sizeof (s), 0, sizeof (s), 0, + 0, spam->rx->pattern, sizeof (s), 0); + mutt_buffer_addstr (buf, s); + if (spam->rx->not) + mutt_buffer_addstr (buf, " )"); + + mutt_buffer_addstr (buf, "\n "); + mutt_format_string (s, sizeof (s), 0, sizeof (s), 0, + 0, spam->template, sizeof (s), 0); + mutt_buffer_addstr (buf, s); + } + return ((old == spam) ? -1 : 0); +} + +static int dump_spam (BUFFER *buf, unsigned long data) +{ + if (data == M_SPAM) + return dump_spam_list (buf); + else + return dump_rx_list (buf, UL &NoSpamList); +} static void remove_from_list (LIST **l, const char *str) { @@ -638,6 +672,44 @@ while (MoreArgs (s)); return 0; +} + +static int dump_list (BUFFER *buf, unsigned long data) +{ + LIST *old, *lst; + char s[STRING]; + if (!buf) + return 1; + for (old = lst = *((LIST **) data); lst; lst = lst->next) + { + mutt_format_string (s, sizeof (s), 0, sizeof (s), 0, + 0, lst->data, sizeof (s), 0); + mutt_buffer_addstr (buf, "\n "); + mutt_buffer_addstr (buf, s); + } + return (old == lst) ? -1 : 0; +} + +static int dump_rx_list (BUFFER *buf, unsigned long data) +{ + RX_LIST *old, *rxl; + char s[STRING]; + if (!buf) + return 1; + for (old = rxl = *((RX_LIST **) data); rxl; rxl = rxl->next) + { + if (!rxl->rx) + return 1; + mutt_buffer_addstr (buf, "\n "); + if (rxl->rx->not) + mutt_buffer_addstr (buf, "!( "); + mutt_format_string (s, sizeof (s), 0, sizeof (s), 0, + 0, rxl->rx->pattern, sizeof (s), 0); + mutt_buffer_addstr (buf, s); + if (rxl->rx->not) + mutt_buffer_addstr (buf, " )"); + } + return ((old == rxl) ? -1 : 0); } static void _alternates_clean (void) @@ -1022,6 +1094,58 @@ } return parse_unattach_list(buf, s, listp, err); +} + +static int _dump_attach_list (BUFFER *buf, LIST *data) +{ + LIST *lst; + char s[SHORT_STRING]; + + if (!buf) + return 1; + for (lst = data; lst; lst = lst->next) + { + mutt_buffer_addstr (buf, "\n "); + mutt_format_string (s, sizeof (s), 0, sizeof (s), 0, + 0, ((ATTACH_MATCH *) lst->data)->major, sizeof (s), 0); + mutt_buffer_addstr (buf, s); + mutt_buffer_addch (buf, '/'); + mutt_format_string (s, sizeof (s), 0, sizeof (s), 0, + 0, ((ATTACH_MATCH *) lst->data)->minor, sizeof (s), 0); + mutt_buffer_addstr (buf, s); + } + return (data == lst) ? -1 : 0; +} + +static int dump_attachments (BUFFER *buf, unsigned long data) +{ + int rv, used = 0; + BUFFER *tmpbuf = NULL; + + if (!buf) + return 1; + +#define DUMP_ATTACH_IF_USED(a,b) \ + tmpbuf = mutt_buffer_from (tmpbuf, "\n " a);\ + if (!(rv = _dump_attach_list (tmpbuf, b)))\ + {\ + used = 1;\ + mutt_buffer_addstr (buf, tmpbuf->data);\ + }\ + mutt_buffer_free (&tmpbuf);\ + if (rv == 1)\ + return 1 + + DUMP_ATTACH_IF_USED("+A", AttachAllow); + DUMP_ATTACH_IF_USED("-A", AttachExclude); + DUMP_ATTACH_IF_USED("+I", InlineAllow); + DUMP_ATTACH_IF_USED("-I", InlineExclude); +#undef DUMP_ATTACH_IF_USED + + if (used) + return 0; + else + return -1; } static int parse_unlists (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) @@ -2768,3 +2901,29 @@ return c->data; return 0; } + +int mutt_dump_command_values (BUFFER *buf, int unused) +{ + int i, rv = 0; + BUFFER *tmpbuf = NULL; + + mutt_buffer_addstr (buf, ""); /* make sure it is initialized */ + + for (i = 0; Commands[i].name; i++) + { + if (Commands[i].dump) + { + tmpbuf = mutt_buffer_init (tmpbuf); + mutt_buffer_addstr (tmpbuf, Commands[i].name); + rv = Commands[i].dump (tmpbuf, Commands[i].data); + mutt_buffer_addstr (tmpbuf, unused ? "\n" : "\n\n"); + if ((unused && rv == -1) || (!unused && !rv)) + mutt_buffer_addstr (buf, tmpbuf->data); + mutt_buffer_free (&tmpbuf); + if (rv == 1) + return 1; + } + } + return i ? 0 : 1; +} + --- a/init.h Tue Oct 4 19:00:05 2005 +++ b/init.h Wed Oct 5 18:36:54 2005 @@ -2992,76 +3008,81 @@ static int parse_alternates (BUFFER *, BUFFER *, unsigned long, BUFFER *); static int parse_unalternates (BUFFER *, BUFFER *, unsigned long, BUFFER *); +static int dump_list (BUFFER *, unsigned long); +static int dump_rx_list (BUFFER *, unsigned long); +static int dump_spam (BUFFER *, unsigned long); +static int dump_attachments (BUFFER *, unsigned long); + struct command_t { char *name; int (*func) (BUFFER *, BUFFER *, unsigned long, BUFFER *); unsigned long data; - unsigned long data1; + int (*dump) (BUFFER *, unsigned long); }; struct command_t Commands[] = { - { "alternates", parse_alternates, 0 }, - { "unalternates", parse_unalternates, 0 }, + { "alternates", parse_alternates, UL &Alternates, dump_rx_list }, + { "unalternates", parse_unalternates, UL &UnAlternates,dump_rx_list}, #ifdef USE_SOCKET - { "account-hook", mutt_parse_hook, M_ACCOUNTHOOK }, + { "account-hook", mutt_parse_hook, M_ACCOUNTHOOK, mutt_dump_hook}, #endif - { "alias", parse_alias, 0 }, - { "attachments", parse_attachments, 0 }, - { "unattachments",parse_unattachments,0 }, - { "auto_view", parse_list, UL &AutoViewList }, - { "alternative_order", parse_list, UL &AlternativeOrderList}, - { "bind", mutt_parse_bind, 0 }, - { "charset-hook", mutt_parse_hook, M_CHARSETHOOK }, + { "alias", parse_alias, 0, NULL /* dump_alias */}, + { "attachments", parse_attachments, 0, dump_attachments }, + { "unattachments", parse_unattachments, 0, NULL }, + { "auto_view", parse_list, UL &AutoViewList, dump_list }, + { "alternative_order",parse_list, UL &AlternativeOrderList, dump_list }, + { "bind", mutt_parse_bind, 0, NULL }, + { "charset-hook", mutt_parse_hook, M_CHARSETHOOK, mutt_dump_hook}, #ifdef HAVE_COLOR - { "color", mutt_parse_color, 0 }, - { "uncolor", mutt_parse_uncolor, 0 }, + { "color", mutt_parse_color, 0, NULL /* dump_color */}, + { "uncolor", mutt_parse_uncolor, 0, NULL }, #endif - { "exec", mutt_parse_exec, 0 }, - { "fcc-hook", mutt_parse_hook, M_FCCHOOK }, - { "fcc-save-hook", mutt_parse_hook, M_FCCHOOK | M_SAVEHOOK }, - { "folder-hook", mutt_parse_hook, M_FOLDERHOOK }, - { "hdr_order", parse_list, UL &HeaderOrderList }, + { "exec", mutt_parse_exec, 0, NULL }, + { "fcc-hook", mutt_parse_hook, M_FCCHOOK, mutt_dump_hook}, + { "fcc-save-hook", mutt_parse_hook, M_FCCHOOK | M_SAVEHOOK, NULL }, + { "folder-hook", mutt_parse_hook, M_FOLDERHOOK, mutt_dump_hook}, + { "hdr_order", parse_list, UL &HeaderOrderList, dump_list }, #ifdef HAVE_ICONV - { "iconv-hook", mutt_parse_hook, M_ICONVHOOK }, + { "iconv-hook", mutt_parse_hook, M_ICONVHOOK, mutt_dump_hook}, #endif - { "ignore", parse_ignore, 0 }, - { "lists", parse_lists, 0 }, - { "macro", mutt_parse_macro, 0 }, - { "mailboxes", mutt_parse_mailboxes, M_MAILBOXES }, - { "unmailboxes", mutt_parse_mailboxes, M_UNMAILBOXES }, - { "message-hook", mutt_parse_hook, M_MESSAGEHOOK }, - { "mbox-hook", mutt_parse_hook, M_MBOXHOOK }, - { "mime_lookup", parse_list, UL &MimeLookupList }, - { "unmime_lookup", parse_unlist, UL &MimeLookupList }, - { "mono", mutt_parse_mono, 0 }, - { "my_hdr", parse_my_hdr, 0 }, - { "pgp-hook", mutt_parse_hook, M_CRYPTHOOK }, - { "crypt-hook", mutt_parse_hook, M_CRYPTHOOK }, - { "push", mutt_parse_push, 0 }, - { "reply-hook", mutt_parse_hook, M_REPLYHOOK }, - { "reset", parse_set, M_SET_RESET }, - { "save-hook", mutt_parse_hook, M_SAVEHOOK }, - { "score", mutt_parse_score, 0 }, - { "send-hook", mutt_parse_hook, M_SENDHOOK }, - { "send2-hook", mutt_parse_hook, M_SEND2HOOK }, - { "set", parse_set, 0 }, - { "source", parse_source, 0 }, - { "spam", parse_spam_list, M_SPAM }, - { "nospam", parse_spam_list, M_NOSPAM }, - { "subscribe", parse_subscribe, 0 }, - { "toggle", parse_set, M_SET_INV }, - { "unalias", parse_unalias, 0 }, - { "unalternative_order",parse_unlist, UL &AlternativeOrderList }, - { "unauto_view", parse_unlist, UL &AutoViewList }, - { "unhdr_order", parse_unlist, UL &HeaderOrderList }, - { "unhook", mutt_parse_unhook, 0 }, - { "unignore", parse_unignore, 0 }, - { "unlists", parse_unlists, 0 }, - { "unmono", mutt_parse_unmono, 0 }, - { "unmy_hdr", parse_unmy_hdr, 0 }, - { "unscore", mutt_parse_unscore, 0 }, - { "unset", parse_set, M_SET_UNSET }, - { "unsubscribe", parse_unsubscribe, 0 }, + { "ignore", parse_ignore, UL &Ignore, dump_list }, + { "unignore", parse_unignore, UL &UnIgnore, dump_list }, + { "lists", parse_lists, UL &MailLists, dump_rx_list }, + { "unlists", parse_unlists, UL &UnMailLists,dump_rx_list }, + { "subscribe", parse_subscribe, UL &SubscribedLists, dump_rx_list }, + { "unsubscribe", parse_unsubscribe,UL &UnSubscribedLists,dump_rx_list }, + { "macro", mutt_parse_macro, 0, NULL }, + { "mailboxes", mutt_parse_mailboxes, M_MAILBOXES, NULL }, + { "unmailboxes", mutt_parse_mailboxes, M_UNMAILBOXES, NULL }, + { "message-hook", mutt_parse_hook, M_MESSAGEHOOK, mutt_dump_hook}, + { "mbox-hook", mutt_parse_hook, M_MBOXHOOK, mutt_dump_hook}, + { "mime_lookup", parse_list, UL &MimeLookupList, dump_list }, + { "unmime_lookup", parse_unlist, UL &MimeLookupList, NULL }, + { "mono", mutt_parse_mono, 0, NULL }, + { "my_hdr", parse_my_hdr, UL &UserHeader, dump_list }, + { "pgp-hook", mutt_parse_hook, M_CRYPTHOOK, mutt_dump_hook}, + { "crypt-hook", mutt_parse_hook, M_CRYPTHOOK, mutt_dump_hook}, + { "push", mutt_parse_push, 0, NULL }, + { "reply-hook", mutt_parse_hook, M_REPLYHOOK, mutt_dump_hook}, + { "reset", parse_set, M_SET_RESET, NULL }, + { "save-hook", mutt_parse_hook, M_SAVEHOOK, mutt_dump_hook}, + { "score", mutt_parse_score, 0 /*UL &Score*/, NULL /*dump_score*/}, + { "send-hook", mutt_parse_hook, M_SENDHOOK, mutt_dump_hook}, + { "send2-hook", mutt_parse_hook, M_SEND2HOOK, mutt_dump_hook}, + { "set", parse_set, 0, NULL }, + { "source", parse_source, 0, NULL }, + { "spam", parse_spam_list, M_SPAM, dump_spam }, + { "nospam", parse_spam_list, M_NOSPAM, dump_spam }, + { "toggle", parse_set, M_SET_INV, NULL }, + { "unalias", parse_unalias, 0, NULL }, + { "unalternative_order",parse_unlist, UL &AlternativeOrderList,NULL }, + { "unauto_view", parse_unlist, UL &AutoViewList, NULL }, + { "unhdr_order", parse_unlist, UL &HeaderOrderList, NULL }, + { "unhook", mutt_parse_unhook, 0, NULL }, + { "unmono", mutt_parse_unmono, 0, NULL }, + { "unmy_hdr", parse_unmy_hdr, 0, NULL }, + { "unscore", mutt_parse_unscore, 0, NULL }, + { "unset", parse_set, M_SET_UNSET, NULL }, { NULL } }; --- a/pager.c Tue Oct 4 19:00:05 2005 +++ b/pager.c Wed Oct 5 18:36:54 2005 @@ -2139,6 +2139,19 @@ mutt_error _("Help is currently being shown."); break; + case OP_STATUS_COMMANDS: + if (! InComval) + { + InComval = 1; + mutt_comval (); + redraw = REDRAW_FULL; + InComval = 0; + } + else + /* from either help or status-commands */ + mutt_error _("You have already invoked status-commands."); + break; + case OP_PAGER_HIDE_QUOTED: if (has_types) { --- a/protos.h Tue Oct 4 19:00:05 2005 +++ b/protos.h Wed Oct 5 18:36:54 2005 @@ -172,6 +172,7 @@ int mutt_count_body_parts (HEADER *hdr, int flags); void mutt_check_rescore (CONTEXT *); void mutt_clear_error (void); +void mutt_comval (void); void mutt_create_alias (ENVELOPE *, ADDRESS *); void mutt_decode_attachment (BODY *, STATE *); void mutt_decode_base64 (STATE *s, long len, int istext, iconv_t cd); @@ -279,6 +281,8 @@ int mutt_copy_body (FILE *, BODY **, BODY *); int mutt_decode_save_attachment (FILE *, BODY *, char *, int, int); int mutt_display_message (HEADER *h); +int mutt_dump_command_values (BUFFER *, int); +int mutt_dump_hook (BUFFER *, unsigned long); int mutt_dump_variables (void); int mutt_edit_attachment(BODY *); int mutt_edit_message (CONTEXT *, HEADER *);