From: Damien Riegel Date: Tue, 8 Nov 2016 02:10:22 +0000 (-0800) Subject: compose: add operation to rename an attachment X-Git-Tag: mutt-1-8-rel~104 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a3c973656d894d305883feaa3c2dd07c03e346b8;p=mutt 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. --- diff --git a/OPS b/OPS index ed15b49e..8bad616c 100644 --- a/OPS +++ b/OPS @@ -36,6 +36,7 @@ OP_COMPOSE_ISPELL "run ispell on the message" 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 --git a/compose.c b/compose.c index b4d0c419..aa59506e 100644 --- a/compose.c +++ b/compose.c @@ -1019,7 +1019,32 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ /* 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 --git a/functions.h b/functions.h index 4f04251e..a0a09d02 100644 --- a/functions.h +++ b/functions.h @@ -350,6 +350,7 @@ const struct binding_t OpCompose[] = { /* map: compose */ { "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" },