--- mutt-1.5.8/PATCHES~ never +++ mutt-1.5.8/PATCHES Tue Mar 8 16:31:42 CST 2005 @@ -1,0 +1 @@ +patch-1.5.8.dgc.xlabel_ext.6 diff -Pur mutt-1.5.8-base/OPS mutt-1.5.8/OPS --- mutt-1.5.8-base/OPS Fri Jul 4 12:07:11 2003 +++ mutt-1.5.8/OPS Tue Mar 8 16:25:25 2005 @@ -56,6 +56,7 @@ OP_DISPLAY_ADDRESS "display full address of sender" OP_DISPLAY_HEADERS "display message and toggle header weeding" OP_DISPLAY_MESSAGE "display a message" +OP_EDIT_LABEL "add, change, or delete a message's label" OP_EDIT_MESSAGE "edit the raw message" OP_EDITOR_BACKSPACE "delete the char in front of the cursor" OP_EDITOR_BACKWARD_CHAR "move the cursor one character to the left" diff -Pur mutt-1.5.8-base/copy.c mutt-1.5.8/copy.c --- mutt-1.5.8-base/copy.c Thu Feb 3 12:47:52 2005 +++ mutt-1.5.8/copy.c Tue Mar 8 16:25:25 2005 @@ -102,6 +102,10 @@ ignore = 0; } + if (flags & CH_UPDATE_LABEL && + mutt_strncasecmp ("X-Label:", buf, 8) == 0) + continue; + if (!ignore && fputs (buf, out) == EOF) return (-1); } @@ -403,6 +407,7 @@ if (fputc ('\n', out) == EOF) return (-1); } + } } @@ -414,6 +419,14 @@ fprintf (out, "Lines: %d\n", h->lines); } + if (flags & CH_UPDATE_LABEL && h->xlabel_changed) + { + if (h->env->x_label != NULL) + if (fprintf(out, "X-Label: %s\n", h->env->x_label) != + 10 + strlen(h->env->x_label)) + return -1; + } + if ((flags & CH_NONEWLINE) == 0) { if (flags & CH_PREFIX) @@ -493,6 +506,9 @@ else _mutt_make_string (prefix, sizeof (prefix), NONULL (Prefix), Context, hdr, 0); } + + if (hdr->xlabel_changed) + chflags |= CH_UPDATE_LABEL; if ((flags & M_CM_NOHEADER) == 0) { diff -Pur mutt-1.5.8-base/curs_main.c mutt-1.5.8/curs_main.c --- mutt-1.5.8-base/curs_main.c Sat Feb 12 13:22:15 2005 +++ mutt-1.5.8/curs_main.c Tue Mar 8 16:25:25 2005 @@ -1851,6 +1851,21 @@ menu->redraw = REDRAW_FULL; break; + case OP_EDIT_LABEL: + + CHECK_MSGCOUNT; + CHECK_READONLY; + rc = mutt_label_message(tag ? NULL : CURHDR); + if (rc > 0) { + Context->changed = 1; + menu->redraw = REDRAW_FULL; + mutt_message ("%d label%s changed.", rc, rc == 1 ? "" : "s"); + } + else { + mutt_message _("No labels changed."); + } + break; + case OP_LIST_REPLY: CHECK_ATTACH; diff -Pur mutt-1.5.8-base/doc/manual.sgml.head mutt-1.5.8/doc/manual.sgml.head --- mutt-1.5.8-base/doc/manual.sgml.head Sat Feb 12 13:41:36 2005 +++ mutt-1.5.8/doc/manual.sgml.head Tue Mar 8 16:25:25 2005 @@ -2321,9 +2321,12 @@ name="$index_format"> variable's ``%y'' and ``%Y'' escapes can be used to expand ``X-Label:'' fields in the index, and Mutt's pattern-matcher can match regular expressions to -``X-Label:'' fields with the ``~y'' selector. ``X-Label:'' is not a +``X-Label:'' fields with the ``˜y'' selector. ``X-Label:'' is not a standard message header field, but it can easily be inserted by procmail and other mail filtering agents. +You can change or delete the ``X-Label:'' field within Mutt using the +``edit-label'' command, bound to the ``y'' key by default. This works +for tagged messages, too. Lastly, Mutt has the ability to the mailbox into . A thread is a group of messages which all relate to the same diff -Pur mutt-1.5.8-base/doc/manual.txt mutt-1.5.8/doc/manual.txt --- mutt-1.5.8-base/doc/manual.txt Sat Feb 12 14:57:49 2005 +++ mutt-1.5.8/doc/manual.txt Tue Mar 8 16:28:21 2005 @@ -2614,9 +2614,12 @@ individually). The ``$index_format'' variable's ``%y'' and ``%Y'' escapes can be used to expand ``X-Label:'' fields in the index, and Mutt's pattern-matcher can match regular expressions to ``X-Label:'' - fields with the ``y'' selector. ``X-Label:'' is not a standard + fields with the ``~y'' selector. ``X-Label:'' is not a standard message header field, but it can easily be inserted by procmail and - other mail filtering agents. + other mail filtering agents. You can change or delete the + ``X-Label:'' field within Mutt using the ``edit-label'' command, + bound to the ``y'' key by default. This works for tagged messages, + too. Lastly, Mutt has the ability to ``sort'' the mailbox into ``threads''. A thread is a group of messages which all relate to the same subject. diff -Pur mutt-1.5.8-base/functions.h mutt-1.5.8/functions.h --- mutt-1.5.8-base/functions.h Fri Jan 28 07:13:12 2005 +++ mutt-1.5.8/functions.h Tue Mar 8 16:25:26 2005 @@ -81,6 +81,7 @@ { "delete-thread", OP_DELETE_THREAD, "\004" }, { "delete-subthread", OP_DELETE_SUBTHREAD, "\033d" }, { "edit", OP_EDIT_MESSAGE, "e" }, + { "edit-label", OP_EDIT_LABEL, "y" }, { "edit-type", OP_EDIT_TYPE, "\005" }, { "forward-message", OP_FORWARD_MESSAGE, "f" }, { "flag-message", OP_FLAG_MESSAGE, "F" }, @@ -163,6 +164,7 @@ { "delete-thread", OP_DELETE_THREAD, "\004" }, { "delete-subthread", OP_DELETE_SUBTHREAD, "\033d" }, { "edit", OP_EDIT_MESSAGE, "e" }, + { "edit-label", OP_EDIT_LABEL, "y" }, { "edit-type", OP_EDIT_TYPE, "\005" }, { "forward-message", OP_FORWARD_MESSAGE, "f" }, { "flag-message", OP_FLAG_MESSAGE, "F" }, diff -Pur mutt-1.5.8-base/headers.c mutt-1.5.8/headers.c --- mutt-1.5.8-base/headers.c Thu Feb 3 12:47:52 2005 +++ mutt-1.5.8/headers.c Tue Mar 8 16:25:26 2005 @@ -205,3 +205,59 @@ } } } + +/* + * dgc: Add an X-Label: field. + */ +static int label_message(HEADER *hdr, char *new) +{ + if (hdr == NULL) + return 0; + if (hdr->env->x_label == NULL && new == NULL) + return 0; + if (hdr->env->x_label != NULL && new != NULL && + strcmp(hdr->env->x_label, new) == 0) + return 0; + if (hdr->env->x_label != NULL) + FREE(&hdr->env->x_label); + if (new == NULL) + hdr->env->x_label = NULL; + else + hdr->env->x_label = safe_strdup(new); + return hdr->changed = hdr->xlabel_changed = 1; +} + +int mutt_label_message(HEADER *hdr) +{ + char buf[LONG_STRING], *new; + int i; + int changed; + + *buf = '\0'; + if (hdr != NULL && hdr->env->x_label != NULL) { + strncpy(buf, hdr->env->x_label, LONG_STRING); + } + + mutt_get_field("Label: ", buf, sizeof(buf), M_CLEAR); + new = buf; + SKIPWS(new); + if (*new == '\0') + new = NULL; + + changed = 0; + if (hdr != NULL) { + changed += label_message(hdr, new); + } else { +#define HDR_OF(index) Context->hdrs[Context->v2r[(index)]] + for (i = 0; i < Context->vcount; ++i) { + if (HDR_OF(i)->tagged) + if (label_message(HDR_OF(i), new)) { + ++changed; + mutt_set_flag(Context, HDR_OF(i), + M_TAG, 0); + } + } + } + + return changed; +} diff -Pur mutt-1.5.8-base/mh.c mutt-1.5.8/mh.c --- mutt-1.5.8-base/mh.c Thu Feb 3 12:47:53 2005 +++ mutt-1.5.8/mh.c Tue Mar 8 16:25:26 2005 @@ -1330,7 +1330,7 @@ { HEADER *h = ctx->hdrs[msgno]; - if (h->attach_del) + if (h->attach_del || h->xlabel_changed) if (mh_rewrite_message (ctx, msgno) != 0) return -1; @@ -1341,7 +1341,7 @@ { HEADER *h = ctx->hdrs[msgno]; - if (h->attach_del) + if (h->attach_del || h->xlabel_changed) { /* when doing attachment deletion, fall back to the MH case. */ if (mh_rewrite_message (ctx, msgno) != 0) @@ -1435,6 +1435,7 @@ } } else if (ctx->hdrs[i]->changed || ctx->hdrs[i]->attach_del || + ctx->hdrs[i]->xlabel_changed || (ctx->magic == M_MAILDIR && (option (OPTMAILDIRTRASH) || ctx->hdrs[i]->trash) && (ctx->hdrs[i]->deleted != ctx->hdrs[i]->trash))) diff -Pur mutt-1.5.8-base/mutt.h mutt-1.5.8/mutt.h --- mutt-1.5.8-base/mutt.h Sat Feb 12 14:01:20 2005 +++ mutt-1.5.8/mutt.h Tue Mar 8 16:25:26 2005 @@ -85,6 +85,8 @@ #define CH_FROM (1<<4) /* retain the "From " message separator? */ #define CH_PREFIX (1<<5) /* use Prefix string? */ #define CH_NOSTATUS (1<<6) /* supress the status and x-status fields */ +/* this absurd location to avoid conflict with cd.edit_threads -- *sigh* */ +#define CH_UPDATE_LABEL (1<<20) /* update X-Label: from hdr->env->x_label? */ #define CH_REORDER (1<<7) /* Re-order output of headers */ #define CH_NONEWLINE (1<<8) /* don't output terminating newline */ #define CH_MIME (1<<9) /* ignore MIME fields */ @@ -707,6 +709,7 @@ * This flag is used by the maildir_trash * option. */ + unsigned int xlabel_changed : 1; /* editable - used for syncing */ /* timezone of the sender of this message */ unsigned int zhours : 5; diff -Pur mutt-1.5.8-base/protos.h mutt-1.5.8/protos.h --- mutt-1.5.8-base/protos.h Tue Feb 1 02:59:02 2005 +++ mutt-1.5.8/protos.h Tue Mar 8 16:25:26 2005 @@ -179,6 +179,7 @@ void mutt_edit_content_type (HEADER *, BODY *, FILE *); void mutt_edit_file (const char *, const char *); void mutt_edit_headers (const char *, const char *, HEADER *, char *, size_t); +int mutt_label_message (HEADER *); void mutt_curses_error (const char *, ...); void mutt_curses_message (const char *, ...); void mutt_enter_command (void);