composing messages with x-label
A colleague's request triggered me into concocting this one
quickly... Not in the CVS at this point; comments welcome.
--
Thomas Roessler <roessler@xxxxxxxxxxxxxxxxxx>
Index: OPS
===================================================================
RCS file: /cvs/mutt/mutt/OPS,v
retrieving revision 3.8
diff -u -r3.8 OPS
--- OPS 8 Sep 2006 18:28:09 -0000 3.8
+++ OPS 11 Jan 2007 15:50:07 -0000
@@ -24,6 +24,7 @@
OP_COMPOSE_EDIT_FILE "edit the file to be attached"
OP_COMPOSE_EDIT_FROM "edit the from field"
OP_COMPOSE_EDIT_HEADERS "edit the message with headers"
+OP_COMPOSE_EDIT_LABEL "edit the message's x-label header"
OP_COMPOSE_EDIT_MESSAGE "edit the message"
OP_COMPOSE_EDIT_MIME "edit attachment using mailcap entry"
OP_COMPOSE_EDIT_REPLY_TO "edit the Reply-To field"
Index: compose.c
===================================================================
RCS file: /cvs/mutt/mutt/compose.c,v
retrieving revision 3.27
diff -u -r3.27 compose.c
--- compose.c 17 Sep 2005 20:46:10 -0000 3.27
+++ compose.c 11 Jan 2007 15:50:09 -0000
@@ -57,6 +57,7 @@
HDR_CC,
HDR_BCC,
HDR_SUBJECT,
+ HDR_LABEL,
HDR_REPLYTO,
HDR_FCC,
@@ -66,7 +67,7 @@
HDR_CRYPT,
HDR_CRYPTINFO,
-
+
HDR_ATTACH = (HDR_FCC + 5) /* where to start printing the attachments */
};
@@ -81,6 +82,7 @@
"Cc: ",
"Bcc: ",
"Subject: ",
+ "Label: ",
"Reply-To: ",
"Fcc: "
};
@@ -257,6 +259,8 @@
draw_envelope_addr (HDR_BCC, msg->env->bcc);
mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
mutt_paddstr (W, NONULL (msg->env->subject));
+ mvprintw (HDR_LABEL, 0, TITLE_FMT, Prompts[HDR_LABEL - 1]);
+ mutt_paddstr (W, NONULL (msg->env->x_label));
draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
mvprintw (HDR_FCC, 0, TITLE_FMT, Prompts[HDR_FCC - 1]);
mutt_paddstr (W, fcc);
@@ -560,6 +564,20 @@
}
mutt_message_hook (NULL, msg, M_SEND2HOOK);
break;
+ case OP_COMPOSE_EDIT_LABEL:
+ if (msg->env->x_label)
+ strfcpy (buf, msg->env->x_label, sizeof (buf));
+ else
+ buf[0] = 0;
+ if (mutt_get_field ("Label: ", buf, sizeof (buf), 0) == 0)
+ {
+ mutt_str_replace (&msg->env->x_label, buf);
+ move (HDR_LABEL, HDR_XOFFSET);
+ clrtoeol ();
+ if (msg->env->x_label)
+ mutt_paddstr (W, msg->env->x_label);
+ }
+ break;
case OP_COMPOSE_EDIT_REPLY_TO:
menu->redraw = edit_address_list (HDR_REPLYTO, &msg->env->reply_to);
mutt_message_hook (NULL, msg, M_SEND2HOOK);
Index: functions.h
===================================================================
RCS file: /cvs/mutt/mutt/functions.h,v
retrieving revision 3.12
diff -u -r3.12 functions.h
--- functions.h 17 Sep 2005 20:46:10 -0000 3.12
+++ functions.h 11 Jan 2007 15:50:10 -0000
@@ -296,6 +296,7 @@
{ "display-toggle-weed", OP_DISPLAY_HEADERS, "h" },
{ "ispell", OP_COMPOSE_ISPELL, "i" },
{ "print-entry", OP_PRINT, "l" },
+ { "edit-label", OP_COMPOSE_EDIT_LABEL, "L" },
{ "edit-mime", OP_COMPOSE_EDIT_MIME, "m" },
{ "new-mime", OP_COMPOSE_NEW_MIME, "n" },
{ "postpone-message", OP_COMPOSE_POSTPONE_MESSAGE, "P" },
Index: init.h
===================================================================
RCS file: /cvs/mutt/mutt/init.h,v
retrieving revision 3.104
diff -u -r3.104 init.h
--- init.h 20 Nov 2006 17:49:56 -0000 3.104
+++ init.h 11 Jan 2007 15:50:12 -0000
@@ -214,7 +214,13 @@
** .pp
** If set, Mutt will prompt you for carbon-copy (Cc) recipients before
** editing the body of an outgoing message.
- */
+ */
+ { "asklabel", DT_BOOL, R_NONE, OPTASKLABEL, 0 },
+ /*
+ ** .pp
+ ** If set, Mutt will prompt you for an X-Label header to be put on
+ ** your outgoing message.
+ */
{ "attach_format", DT_STR, R_NONE, UL &AttachFormat, UL "%u%D%I %t%4n
%T%.40d%> [%.7m/%.10M, %.6e%?C?, %C?, %s] " },
/*
** .pp
Index: mutt.h
===================================================================
RCS file: /cvs/mutt/mutt/mutt.h,v
retrieving revision 3.69
diff -u -r3.69 mutt.h
--- mutt.h 2 Jan 2007 17:10:34 -0000 3.69
+++ mutt.h 11 Jan 2007 15:50:12 -0000
@@ -331,6 +331,7 @@
OPTASCIICHARS,
OPTASKBCC,
OPTASKCC,
+ OPTASKLABEL,
OPTATTACHSPLIT,
OPTAUTOEDIT,
OPTAUTOTAG,
Index: send.c
===================================================================
RCS file: /cvs/mutt/mutt/send.c,v
retrieving revision 3.46
diff -u -r3.46 send.c
--- send.c 5 Sep 2006 08:57:37 -0000 3.46
+++ send.c 11 Jan 2007 15:50:13 -0000
@@ -237,7 +237,7 @@
char *p;
buf[0] = 0;
- for (; uh; uh = uh->next)
+ for (uh = UserHeader; uh; uh = uh->next)
{
if (ascii_strncasecmp ("subject:", uh->data, 8) == 0)
{
@@ -256,6 +256,26 @@
}
mutt_str_replace (&en->subject, buf);
+ if (en->x_label)
+ {
+ strfcpy (buf, en->x_label, sizeof (buf));
+ }
+ else
+ {
+ for (uh = UserHeader; uh; uh = uh->next)
+ {
+ if (ascii_strncasecmp ("x-label:", uh->data, 8) == 0)
+ {
+ char *p = uh->data + 8;
+ SKIPWS (p);
+ strncpy (buf, p, sizeof (buf));
+ }
+ }
+ }
+
+ if (mutt_get_field ("Label: ", buf, sizeof (buf), 0) == 0)
+ mutt_str_replace (&en->x_label, buf);
+
return 0;
}
Index: sendlib.c
===================================================================
RCS file: /cvs/mutt/mutt/sendlib.c,v
retrieving revision 3.42
diff -u -r3.42 sendlib.c
--- sendlib.c 9 Jan 2007 10:29:09 -0000 3.42
+++ sendlib.c 11 Jan 2007 15:50:14 -0000
@@ -1797,6 +1797,9 @@
fputc ('\n', fp);
}
+ if (env->x_label)
+ mutt_write_one_header (fp, "X-Label", env->x_label, NULL, 0);
+
/* Add any user defined headers */
for (; tmp; tmp = tmp->next)
{