changeset: 6837:a9e7402af4de user: Damien Riegel <damien.rie...@gmail.com> date: Mon Nov 07 18:06:13 2016 -0800 link: http://dev.mutt.org/hg/mutt/rev/a9e7402af4de
attach_format: add new %F placeholder This new placeholder allows to print the attachment name as it will be seen on the recipient side. changeset: 6838:82e566d393cf user: Damien Riegel <damien.rie...@gmail.com> date: Mon Nov 07 18:10:22 2016 -0800 link: http://dev.mutt.org/hg/mutt/rev/82e566d393cf compose: add operation to rename an attachment As opposed to rename-file, which actually renames the underlying file of the attachment, rename-attachment puts a value in d_filename, which is used in the Content-Disposition header. changeset: 6839:d0078268768d user: Kevin McCarthy <ke...@8t8.us> date: Mon Nov 07 18:10:27 2016 -0800 link: http://dev.mutt.org/hg/mutt/rev/d0078268768d Chain %d->%F->%f in the attachment menu. Previously, %d would use %f if there was no description set. Place the new %F option in between %d and %f. This way, %d will fall back on %F, which will fall back on %f. This allows the standard attachment menu to show d_filename. This is useful for forwarding attachments or editing draft files with attachments. In these cases the actual filename is sanitized but the attachment name is preserved in d_filename. diffs (112 lines): diff -r 45023e44c92c -r d0078268768d OPS --- a/OPS Thu Nov 03 15:49:50 2016 -0700 +++ b/OPS Mon Nov 07 18:10:27 2016 -0800 @@ -36,6 +36,7 @@ OP_COMPOSE_NEW_MIME "compose new attachment using mailcap entry" OP_COMPOSE_TOGGLE_RECODE "toggle recoding of this attachment" OP_COMPOSE_POSTPONE_MESSAGE "save this message to send later" +OP_COMPOSE_RENAME_ATTACHMENT "send attachment with a different name" OP_COMPOSE_RENAME_FILE "rename/move an attached file" OP_COMPOSE_SEND_MESSAGE "send the message" OP_COMPOSE_TOGGLE_DISPOSITION "toggle disposition between inline/attachment" diff -r 45023e44c92c -r d0078268768d compose.c --- a/compose.c Thu Nov 03 15:49:50 2016 -0700 +++ b/compose.c Mon Nov 07 18:10:27 2016 -0800 @@ -1019,7 +1019,32 @@ /* No send2hook since this doesn't change the message. */ break; - + + case OP_COMPOSE_RENAME_ATTACHMENT: + { + char *src; + int ret; + + CHECK_COUNT; + if (idx[menu->current]->content->d_filename) + src = idx[menu->current]->content->d_filename; + else + src = idx[menu->current]->content->filename; + strfcpy (fname, mutt_basename (NONULL (src)), sizeof (fname)); + ret = mutt_get_field (_("Send attachment with name: "), + fname, sizeof (fname), MUTT_FILE); + if (ret == 0) + { + /* + * As opposed to RENAME_FILE, we don't check fname[0] because it's + * valid to set an empty string here, to erase what was set + */ + mutt_str_replace (&idx[menu->current]->content->d_filename, fname); + menu->redraw = REDRAW_CURRENT; + } + } + break; + case OP_COMPOSE_RENAME_FILE: CHECK_COUNT; strfcpy (fname, idx[menu->current]->content->filename, sizeof (fname)); diff -r 45023e44c92c -r d0078268768d functions.h --- a/functions.h Thu Nov 03 15:49:50 2016 -0700 +++ b/functions.h Mon Nov 07 18:10:27 2016 -0800 @@ -350,6 +350,7 @@ { "new-mime", OP_COMPOSE_NEW_MIME, "n" }, { "postpone-message", OP_COMPOSE_POSTPONE_MESSAGE, "P" }, { "edit-reply-to", OP_COMPOSE_EDIT_REPLY_TO, "r" }, + { "rename-attachment",OP_COMPOSE_RENAME_ATTACHMENT, "\017" }, { "rename-file", OP_COMPOSE_RENAME_FILE, "R" }, { "edit-subject", OP_COMPOSE_EDIT_SUBJECT, "s" }, { "edit-to", OP_COMPOSE_EDIT_TO, "t" }, diff -r 45023e44c92c -r d0078268768d init.h --- a/init.h Thu Nov 03 15:49:50 2016 -0700 +++ b/init.h Mon Nov 07 18:10:27 2016 -0800 @@ -225,6 +225,7 @@ ** .dt %D .dd deleted flag ** .dt %d .dd description ** .dt %e .dd MIME content-transfer-encoding + ** .dt %F .dd filename for content-disposition header ** .dt %f .dd filename ** .dt %I .dd disposition (``I'' for inline, ``A'' for attachment) ** .dt %m .dd major MIME type diff -r 45023e44c92c -r d0078268768d recvattach.c --- a/recvattach.c Thu Nov 03 15:49:50 2016 -0700 +++ b/recvattach.c Mon Nov 07 18:10:27 2016 -0800 @@ -160,6 +160,7 @@ * %D = deleted flag * %d = description * %e = MIME content-transfer-encoding + * %F = filename for content-disposition header * %f = filename * %I = content-disposition, either I (inline) or A (attachment) * %t = tagged flag @@ -235,7 +236,7 @@ break; } } - if (!aptr->content->filename) + if (!aptr->content->d_filename && !aptr->content->filename) { mutt_format_s (dest, destlen, prefix, "<no description>"); break; @@ -245,6 +246,21 @@ (mutt_is_message_type (aptr->content->type, aptr->content->subtype) && MsgFmt && aptr->content->hdr)) break; + /* FALLS THROUGH TO 'F' */ + case 'F': + if (!optional) + { + if (aptr->content->d_filename) + { + mutt_format_s (dest, destlen, prefix, aptr->content->d_filename); + break; + } + } + else if (!aptr->content->d_filename && !aptr->content->filename) + { + optional = 0; + break; + } /* FALLS THROUGH TO 'f' */ case 'f': if(!optional)