From 1fec6469f33e8be5ccdb82c9a3188d04d8c3698b Mon Sep 17 00:00:00 2001 From: Seth Arnold Date: Fri, 15 May 2009 12:46:33 +0200 Subject: [PATCH] Make "uncolor" also work header and body objects. Closes #1046. --- UPDATING | 1 + color.c | 31 ++++++++++++++++++------------- doc/manual.xml.head | 43 ++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 59 insertions(+), 16 deletions(-) diff --git a/UPDATING b/UPDATING index 0e34d4028..50c735d50 100644 --- a/UPDATING +++ b/UPDATING @@ -5,6 +5,7 @@ The keys used are: !: modified feature, -: deleted feature, +: new feature hg tip: + + uncolor works for header + body objects, too + the "flagged" and "replied" flags are enabled/supported for POP when built with header caching + and work in the pager, too diff --git a/color.c b/color.c index 0288eb194..b39957f0c 100644 --- a/color.c +++ b/color.c @@ -364,12 +364,12 @@ int mutt_parse_unmono (BUFFER *buf, BUFFER *s, unsigned long data, return _mutt_parse_uncolor(buf, s, data, err, 0); } -static int -_mutt_parse_uncolor (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err, - short parse_uncolor) +static int _mutt_parse_uncolor (BUFFER *buf, BUFFER *s, unsigned long data, + BUFFER *err, short parse_uncolor) { int object = 0, do_cache = 0; COLOR_LINE *tmp, *last = NULL; + COLOR_LINE **list; mutt_extract_token (buf, s, 0); @@ -379,14 +379,20 @@ _mutt_parse_uncolor (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err, return (-1); } - if (mutt_strncmp (buf->data, "index", 5) != 0) + if (mutt_strncmp (buf->data, "index", 5) == 0) + list = &ColorIndexList; + else if (mutt_strncmp (buf->data, "body", 4) == 0) + list = &ColorBodyList; + else if (mutt_strncmp (buf->data, "header", 7) == 0) + list = &ColorHdrList; + else { snprintf (err->data, err->dsize, - _("%s: command valid only for index object"), + _("%s: command valid only for index, body, header objects"), parse_uncolor ? "uncolor" : "unmono"); return (-1); } - + if (!MoreArgs (s)) { snprintf (err->data, err->dsize, @@ -415,14 +421,13 @@ _mutt_parse_uncolor (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err, return 0; } - - + do { mutt_extract_token (buf, s, 0); if (!mutt_strcmp ("*", buf->data)) { - for (tmp = ColorIndexList; tmp; ) + for (tmp = *list; tmp; ) { if (!do_cache) do_cache = 1; @@ -430,22 +435,22 @@ _mutt_parse_uncolor (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err, tmp = tmp->next; mutt_free_color_line(&last, parse_uncolor); } - ColorIndexList = NULL; + *list = NULL; } else { - for (last = NULL, tmp = ColorIndexList; tmp; last = tmp, tmp = tmp->next) + for (last = NULL, tmp = *list; tmp; last = tmp, tmp = tmp->next) { if (!mutt_strcmp (buf->data, tmp->pattern)) { if (!do_cache) do_cache = 1; - dprint(1,(debugfile,"Freeing pattern \"%s\" from ColorIndexList\n", + dprint(1,(debugfile,"Freeing pattern \"%s\" from color list\n", tmp->pattern)); if (last) last->next = tmp->next; else - ColorIndexList = tmp->next; + *list = tmp->next; mutt_free_color_line(&tmp, parse_uncolor); break; } diff --git a/doc/manual.xml.head b/doc/manual.xml.head index e684d0af5..27b382ef5 100644 --- a/doc/manual.xml.head +++ b/doc/manual.xml.head @@ -2467,9 +2467,17 @@ silently truncated at the screen width, and are not wrapped. uncolor + + + + + + + + * @@ -2561,10 +2569,10 @@ setting this variable. -The uncolor command can be applied to the index object only. It +The uncolor command can be applied to the index, header and body objects only. It removes entries from the list. You must specify the same pattern specified in the color command for it to be removed. The pattern * is -a special token which means to clear the color index list of all entries. +a special token which means to clear the color list of all entries. @@ -2619,9 +2627,17 @@ attributes through the use of the mono command. Usage: unmono + + + + + + + + * @@ -7842,12 +7858,25 @@ The following are the commands understood by Mutt: uncolor + + + + + + + + + + +* + -pattern +pattern + @@ -8148,9 +8177,17 @@ The following are the commands understood by Mutt: unmono + + + + + + + + * -- 2.40.0