]> granicus.if.org Git - mutt/commitdiff
compose: add operation to rename an attachment
authorDamien Riegel <damien.riegel@gmail.com>
Tue, 8 Nov 2016 02:10:22 +0000 (18:10 -0800)
committerDamien Riegel <damien.riegel@gmail.com>
Tue, 8 Nov 2016 02:10:22 +0000 (18:10 -0800)
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.

OPS
compose.c
functions.h

diff --git a/OPS b/OPS
index ed15b49edf312daf7c3e4679d66febf7745719a0..8bad616c40294744e19bf938295b08a69decf775 100644 (file)
--- 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"
index b4d0c41983046d53836c68b89769b5bb56614625..aa59506e1bc824fb3df0bbfd31a2862e3969f752 100644 (file)
--- 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));
index 4f04251e5e701589ba729dd54a0d8a46fe8a5ae6..a0a09d021729bca98e5af12c651e7e296dd03703 100644 (file)
@@ -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" },