diff -U 8 -r mutt-1.5.20/OPS mutt-1.5.20-with-x-label/OPS
--- mutt-1.5.20/OPS 2009-05-12 22:01:13.000000000 -0700
+++ mutt-1.5.20-with-x-label/OPS 2011-12-12 15:47:48.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.20/PATCHES mutt-1.5.20-with-x-label/PATCHES
--- mutt-1.5.20/PATCHES 2008-11-11 11:55:46.000000000 -0800
+++ mutt-1.5.20-with-x-label/PATCHES 2011-12-12 15:48:52.000000000 -0800
@@ -0,0 +1 @@
+dgc.xlabel_ext.5
diff -U 8 -r mutt-1.5.20/copy.c mutt-1.5.20-with-x-label/copy.c
--- mutt-1.5.20/copy.c 2009-06-12 16:38:52.000000000 -0700
+++ mutt-1.5.20-with-x-label/copy.c 2011-12-12 15:47:48.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.20/copy.h mutt-1.5.20-with-x-label/copy.h
--- mutt-1.5.20/copy.h 2009-06-12 16:38:52.000000000 -0700
+++ mutt-1.5.20-with-x-label/copy.h 2011-12-12 15:47:48.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.20/curs_main.c mutt-1.5.20-with-x-label/curs_main.c
--- mutt-1.5.20/curs_main.c 2009-06-13 19:48:36.000000000 -0700
+++ mutt-1.5.20-with-x-label/curs_main.c 2011-12-12 15:47:48.000000000 -0800
@@ -1921,16 +1921,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.20/doc/manual.txt mutt-1.5.20-with-x-label/doc/manual.txt
--- mutt-1.5.20/doc/manual.txt 2009-06-14 11:54:56.000000000 -0700
+++ mutt-1.5.20-with-x-label/doc/manual.txt 2011-12-12 15:47:48.000000000 -0800
@@ -4065,19 +4065,22 @@
whether or not you would like to use the address given in the ?Reply-To? field,
or reply directly to the address given in the ?From? field. When set to yes,
the ?Reply-To? field will be used when present.
The ?X-Label:? header field can be used to further identify mailing lists or
list subject matter (or just to annotate messages individually). The
$index_format variable's ?%y? and ?%Y? expandos 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
+expressions to ?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.
+other mail filtering agents. The ?X-Label:? header can be changed or deleted
+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. This is usually
organized into a tree-like structure where a message and all of its replies are
represented graphically. If you've ever used a threaded news client, this is
the same concept. It makes dealing with large volume mailing lists easier
because you can easily delete uninteresting threads and quickly find topics of
value.
diff -U 8 -r mutt-1.5.20/doc/manual.xml.head mutt-1.5.20-with-x-label/doc/manual.xml.head
--- mutt-1.5.20/doc/manual.xml.head 2009-05-30 10:20:08.000000000 -0700
+++ mutt-1.5.20-with-x-label/doc/manual.xml.head 2011-12-12 15:47:48.000000000 -0800
@@ -5437,17 +5437,20 @@
The X-Label:
header field can be used to further identify mailing
lists or list subject matter (or just to annotate messages
individually). The $index_format variable's %y
and
%Y
expandos 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 message header field, but it can easily be inserted by procmail
-and other mail filtering agents.
+and other mail filtering agents. The X-Label:
header can be
+changed or deleted 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. This is usually organized into a tree-like structure where a
message and all of its replies are represented graphically. If you've ever
used a threaded news client, this is the same concept. It makes dealing
diff -U 8 -r mutt-1.5.20/functions.h mutt-1.5.20-with-x-label/functions.h
--- mutt-1.5.20/functions.h 2009-04-29 22:36:17.000000000 -0700
+++ mutt-1.5.20-with-x-label/functions.h 2011-12-12 15:50:25.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
@@ -181,16 +182,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 },
#endif
{ "display-toggle-weed", OP_DISPLAY_HEADERS, "h" },
diff -U 8 -r mutt-1.5.20/headers.c mutt-1.5.20-with-x-label/headers.c
--- mutt-1.5.20/headers.c 2009-04-29 22:36:17.000000000 -0700
+++ mutt-1.5.20-with-x-label/headers.c 2011-12-12 15:47:48.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.20/mutt.h mutt-1.5.20-with-x-label/mutt.h
--- mutt-1.5.20/mutt.h 2009-06-12 15:15:42.000000000 -0700
+++ mutt-1.5.20-with-x-label/mutt.h 2011-12-12 15:47:48.000000000 -0800
@@ -714,16 +714,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.20/protos.h mutt-1.5.20-with-x-label/protos.h
--- mutt-1.5.20/protos.h 2009-06-12 16:38:52.000000000 -0700
+++ mutt-1.5.20-with-x-label/protos.h 2011-12-12 15:47:48.000000000 -0800
@@ -182,16 +182,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_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 *);
void mutt_expand_link (char *, const char *, const char *);