diff -ru mutt-1.3.8-dist/OPS mutt-1.3.8/OPS --- mutt-1.3.8-dist/OPS Mon Aug 21 10:42:09 2000 +++ mutt-1.3.8/OPS Sat Sep 9 19:33:06 2000 @@ -53,6 +53,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 -ru mutt-1.3.8-dist/copy.c mutt-1.3.8/copy.c --- mutt-1.3.8-dist/copy.c Fri Jul 7 01:36:15 2000 +++ mutt-1.3.8/copy.c Sat Sep 9 19:03:35 2000 @@ -94,6 +94,10 @@ ignore = 0; } + if (flags & CH_UPDATE_LABEL && + mutt_strncasecmp ("X-Label:", buf, 8) == 0) + continue; + if (!ignore && fputs (buf, out) == EOF) return (-1); } @@ -346,6 +350,7 @@ if (fputc ('\n', out) == EOF) return (-1); } + } } @@ -357,6 +362,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) @@ -430,6 +443,9 @@ if (flags & M_CM_PREFIX) _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 -ru mutt-1.3.8-dist/curs_main.c mutt-1.3.8/curs_main.c --- mutt-1.3.8-dist/curs_main.c Wed Aug 30 04:59:43 2000 +++ mutt-1.3.8/curs_main.c Sat Sep 9 19:33:19 2000 @@ -1644,6 +1644,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 -ru mutt-1.3.8-dist/doc/manual.sgml.head mutt-1.3.8/doc/manual.sgml.head --- mutt-1.3.8-dist/doc/manual.sgml.head Tue Aug 22 09:52:42 2000 +++ mutt-1.3.8/doc/manual.sgml.head Sat Sep 9 19:23:56 2000 @@ -2012,9 +2012,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 -ru mutt-1.3.8-dist/doc/manual.txt mutt-1.3.8/doc/manual.txt --- mutt-1.3.8-dist/doc/manual.txt Wed Aug 30 05:10:06 2000 +++ mutt-1.3.8/doc/manual.txt Sat Sep 9 19:27:05 2000 @@ -2253,9 +2253,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 -ru mutt-1.3.8-dist/functions.h mutt-1.3.8/functions.h --- mutt-1.3.8-dist/functions.h Mon Aug 21 10:42:09 2000 +++ mutt-1.3.8/functions.h Sat Sep 9 19:31:34 2000 @@ -78,6 +78,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" }, @@ -156,6 +157,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 -ru mutt-1.3.8-dist/headers.c mutt-1.3.8/headers.c --- mutt-1.3.8-dist/headers.c Wed Apr 12 11:31:37 2000 +++ mutt-1.3.8/headers.c Sat Sep 9 19:28:53 2000 @@ -206,3 +206,59 @@ if (!in_reply_to) mutt_free_list (&msg->env->references); } + +/* + * 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 -ru mutt-1.3.8-dist/mutt.h mutt-1.3.8/mutt.h --- mutt-1.3.8-dist/mutt.h Fri Jul 28 03:52:12 2000 +++ mutt-1.3.8/mutt.h Sat Sep 9 19:03:35 2000 @@ -77,6 +77,7 @@ #define CH_NOLEN (1<<12) /* don't write Content-Length: and Lines: */ #define CH_WEED_DELIVERED (1<<13) /* weed eventual Delivered-To headers */ #define CH_FORCE_FROM (1<<14) /* give CH_FROM precedence over CH_WEED? */ +#define CH_UPDATE_LABEL (1<<15) /* update X-Label: from hdr->env->x_label? */ /* flags for mutt_enter_string() */ #define M_ALIAS 1 /* do alias "completion" by calling up the alias-menu */ @@ -584,6 +585,7 @@ unsigned int threaded : 1; /* message has been threaded */ unsigned int recip_valid : 1; /* is_recipient is valid */ unsigned int active : 1; /* message is not to be removed */ + unsigned int xlabel_changed : 1; /* editable - used for syncing */ /* timezone of the sender of this message */ unsigned int zhours : 5; diff -ru mutt-1.3.8-dist/protos.h mutt-1.3.8/protos.h --- mutt-1.3.8-dist/protos.h Mon Aug 28 04:38:01 2000 +++ mutt-1.3.8/protos.h Sat Sep 9 19:03:35 2000 @@ -149,6 +149,7 @@ void mutt_edit_content_type (HEADER *, BODY *); 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_enter_command (void); void mutt_expand_aliases_env (ENVELOPE *);