]> granicus.if.org Git - mutt/commitdiff
Chain %d->%F->%f in the attachment menu.
authorKevin McCarthy <kevin@8t8.us>
Tue, 8 Nov 2016 02:10:27 +0000 (18:10 -0800)
committerKevin McCarthy <kevin@8t8.us>
Tue, 8 Nov 2016 02:10:27 +0000 (18:10 -0800)
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.

recvattach.c

index 9693827e0b4f4bbf44c778fb934da180416444eb..562c6b553bf7b08fac7a1f948bae62f754e3d572 100644 (file)
@@ -236,7 +236,7 @@ const char *mutt_attach_fmt (char *dest,
            break;
          }
        }
-       if (!aptr->content->filename)
+        if (!aptr->content->d_filename && !aptr->content->filename)
        {
          mutt_format_s (dest, destlen, prefix, "<no description>");
          break;
@@ -246,6 +246,21 @@ const char *mutt_attach_fmt (char *dest,
              (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)
@@ -264,25 +279,6 @@ const char *mutt_attach_fmt (char *dest,
       else if(!aptr->content->filename)
         optional = 0;
       break;
-    case 'F':
-      if (!optional)
-      {
-        char fname[_POSIX_PATH_MAX];
-        char *src = NULL;
-
-        if (aptr->content->d_filename)
-          src = aptr->content->d_filename;
-        else if (aptr->content->filename)
-          src = aptr->content->filename;
-        else
-          break;
-
-        strfcpy (fname, mutt_basename (NONULL (src)), sizeof (fname));
-        mutt_format_s (dest, destlen, prefix, fname);
-      }
-      else if (!aptr->content->d_filename && !aptr->content->filename)
-        optional = 0;
-      break;
     case 'D':
       if(!optional)
        snprintf (dest, destlen, "%c", aptr->content->deleted ? 'D' : ' ');