diff -U 8 -r mutt-1.5.21/OPS mutt-1.5.21-with-x-label/OPS --- mutt-1.5.21/OPS 2010-03-01 09:56:19.000000000 -0800 +++ mutt-1.5.21-with-x-label/OPS 2011-12-12 15:53:47.000000000 -0800 @@ -51,16 +51,17 @@ OP_DECODE_SAVE "make decoded copy (text/plain) and delete" OP_DELETE "delete the current entry" OP_DELETE_MAILBOX "delete the current mailbox (IMAP only)" OP_DELETE_SUBTHREAD "delete all messages in subthread" OP_DELETE_THREAD "delete all messages in thread" 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" OP_EDITOR_BACKWARD_WORD "move the cursor to the beginning of the word" OP_EDITOR_BOL "jump to the beginning of the line" OP_EDITOR_BUFFY_CYCLE "cycle among incoming mailboxes" OP_EDITOR_COMPLETE "complete filename or alias" OP_EDITOR_COMPLETE_QUERY "complete address with query" diff -U 8 -r mutt-1.5.21/PATCHES mutt-1.5.21-with-x-label/PATCHES --- mutt-1.5.21/PATCHES 2008-03-19 13:07:06.000000000 -0700 +++ mutt-1.5.21-with-x-label/PATCHES 2011-12-12 15:53:47.000000000 -0800 @@ -0,0 +1 @@ +dgc.xlabel_ext.5 diff -U 8 -r mutt-1.5.21/copy.c mutt-1.5.21-with-x-label/copy.c --- mutt-1.5.21/copy.c 2010-03-02 11:15:00.000000000 -0800 +++ mutt-1.5.21-with-x-label/copy.c 2011-12-12 15:53:47.000000000 -0800 @@ -106,16 +106,20 @@ ascii_strncasecmp ("References:", buf, 11) == 0) continue; if ((flags & CH_UPDATE_IRT) && ascii_strncasecmp ("In-Reply-To:", buf, 12) == 0) continue; ignore = 0; } + if (flags & CH_UPDATE_LABEL && + mutt_strncasecmp ("X-Label:", buf, 8) == 0) + continue; + if (!ignore && fputs (buf, out) == EOF) return (-1); } return 0; } hdr_count = 1; x = 0; @@ -407,16 +411,24 @@ if (flags & CH_UPDATE_LEN && (flags & CH_NOLEN) == 0) { fprintf (out, "Content-Length: " OFF_T_FMT "\n", h->content->length); if (h->lines != 0 || h->content->length == 0) 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) fputs(prefix, out); fputc ('\n', out); /* add header terminator */ } if (ferror (out) || feof (out)) @@ -487,16 +499,19 @@ if (flags & M_CM_PREFIX) { if (option (OPTTEXTFLOWED)) strfcpy (prefix, ">", sizeof (prefix)); 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) { if (flags & M_CM_PREFIX) chflags |= CH_PREFIX; else if (hdr->attach_del && (chflags & CH_UPDATE_LEN)) { int new_lines; diff -U 8 -r mutt-1.5.21/copy.h mutt-1.5.21-with-x-label/copy.h --- mutt-1.5.21/copy.h 2009-08-25 12:08:52.000000000 -0700 +++ mutt-1.5.21-with-x-label/copy.h 2011-12-12 15:53:47.000000000 -0800 @@ -36,16 +36,18 @@ /* flags for mutt_copy_header() */ #define CH_UPDATE 1 /* update the status and x-status fields? */ #define CH_WEED (1<<1) /* weed the headers? */ #define CH_DECODE (1<<2) /* do RFC1522 decoding? */ #define CH_XMIT (1<<3) /* transmitting this message? */ #define CH_FROM (1<<4) /* retain the "From " message separator? */ #define CH_PREFIX (1<<5) /* use Prefix string? */ #define CH_NOSTATUS (1<<6) /* suppress 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 */ #define CH_UPDATE_LEN (1<<10) /* update Lines: and Content-Length: */ #define CH_TXTPLAIN (1<<11) /* generate text/plain MIME headers */ #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? */ diff -U 8 -r mutt-1.5.21/curs_main.c mutt-1.5.21-with-x-label/curs_main.c --- mutt-1.5.21/curs_main.c 2010-09-13 10:19:55.000000000 -0700 +++ mutt-1.5.21-with-x-label/curs_main.c 2011-12-12 15:53:47.000000000 -0800 @@ -1941,16 +1941,31 @@ CHECK_VISIBLE; CHECK_ATTACH; if (option (OPTPGPAUTODEC) && (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))) mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw); ci_send_message (SENDREPLY|SENDGROUPREPLY, NULL, NULL, Context, tag ? NULL : CURHDR); 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; CHECK_MSGCOUNT; CHECK_VISIBLE; if (option (OPTPGPAUTODEC) && (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))) mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw); ci_send_message (SENDREPLY|SENDLISTREPLY, NULL, NULL, Context, tag ? NULL : CURHDR); diff -U 8 -r mutt-1.5.21/functions.h mutt-1.5.21-with-x-label/functions.h --- mutt-1.5.21/functions.h 2010-08-24 09:34:21.000000000 -0700 +++ mutt-1.5.21-with-x-label/functions.h 2011-12-12 15:53:47.000000000 -0800 @@ -94,16 +94,17 @@ { "copy-message", OP_COPY_MESSAGE, "C" }, { "decode-copy", OP_DECODE_COPY, "\033C" }, { "decode-save", OP_DECODE_SAVE, "\033s" }, { "delete-message", OP_DELETE, "d" }, { "delete-pattern", OP_MAIN_DELETE_PATTERN, "D" }, { "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" }, { "group-reply", OP_GROUP_REPLY, "g" }, #ifdef USE_POP { "fetch-mail", OP_MAIN_FETCH_MAIL, "G" }, #endif #ifdef USE_IMAP @@ -182,16 +183,17 @@ { "copy-message", OP_COPY_MESSAGE, "C" }, { "decode-copy", OP_DECODE_COPY, "\033C" }, { "delete-message", OP_DELETE, "d" }, { "delete-thread", OP_DELETE_THREAD, "\004" }, { "delete-subthread", OP_DELETE_SUBTHREAD, "\033d" }, { "set-flag", OP_MAIN_SET_FLAG, "w" }, { "clear-flag", OP_MAIN_CLEAR_FLAG, "W" }, { "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" }, { "group-reply", OP_GROUP_REPLY, "g" }, #ifdef USE_IMAP { "imap-fetch-mail", OP_MAIN_IMAP_FETCH, NULL }, { "imap-logout-all", OP_MAIN_IMAP_LOGOUT_ALL, NULL }, #endif diff -U 8 -r mutt-1.5.21/headers.c mutt-1.5.21-with-x-label/headers.c --- mutt-1.5.21/headers.c 2009-08-25 12:08:52.000000000 -0700 +++ mutt-1.5.21-with-x-label/headers.c 2011-12-12 15:53:47.000000000 -0800 @@ -210,8 +210,64 @@ tmp = cur; *last = cur->next; cur = cur->next; tmp->next = NULL; mutt_free_list (&tmp); } } } + +/* + * 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 -U 8 -r mutt-1.5.21/mutt.h mutt-1.5.21-with-x-label/mutt.h --- mutt-1.5.21/mutt.h 2010-09-13 10:19:55.000000000 -0700 +++ mutt-1.5.21-with-x-label/mutt.h 2011-12-12 15:53:47.000000000 -0800 @@ -719,16 +719,18 @@ unsigned int display_subject : 1; /* used for threading */ unsigned int recip_valid : 1; /* is_recipient is valid */ unsigned int active : 1; /* message is not to be removed */ unsigned int trash : 1; /* message is marked as trashed on disk. * 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; unsigned int zminutes : 6; unsigned int zoccident : 1; /* bits used for caching when searching */ unsigned int searched : 1; unsigned int matched : 1; diff -U 8 -r mutt-1.5.21/protos.h mutt-1.5.21-with-x-label/protos.h --- mutt-1.5.21/protos.h 2010-08-24 09:34:21.000000000 -0700 +++ mutt-1.5.21-with-x-label/protos.h 2011-12-12 15:55:09.000000000 -0800 @@ -177,16 +177,17 @@ void mutt_decode_attachment (BODY *, STATE *); void mutt_decode_base64 (STATE *s, long len, int istext, iconv_t cd); void mutt_default_save (char *, size_t, HEADER *); void mutt_display_address (ENVELOPE *); void mutt_display_sanitize (char *); 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 *); int mutt_filter_unprintable (char **); void mutt_curses_error (const char *, ...); void mutt_curses_message (const char *, ...); void mutt_encode_path (char *, size_t, const char *); void mutt_enter_command (void); void mutt_expand_aliases_env (ENVELOPE *); void mutt_expand_file_fmt (char *, size_t, const char *, const char *); void mutt_expand_fmt (char *, size_t, const char *, const char *);