On Fri, Nov 04, 2016 at 06:04:01PM -0400, Damien Riegel wrote:
> This new placeholder allows to print the attachment name as it will be
> seen on the recipient side.

Hi Damien,

I'm just curious if you tried putting the new "%F" option case statement
above the "%f", and having it fall through if d_filename is NULL?

This way, by default (with %d), the user sees content->description if
there is one, then content->d_filename if there is one, and falling back
to content->filename.

This also keeps the mutt_pretty_mailbox() call in %f.

I'm attaching a (very lightly tested) patch based on top of yours.
What do you think?

-- 
Kevin J. McCarthy
GPG Fingerprint: 8975 A9B3 3AA3 7910 385C  5308 ADEF 7684 8031 6BDA
# HG changeset patch
# User Kevin McCarthy <[email protected]>
# Date 1478379979 25200
#      Sat Nov 05 14:06:19 2016 -0700
# Node ID 783426bfe2ab4dea48ede21d63befd6993789a53
# Parent  ad8a99eee4652897836a0d288b567eab3010c49c
[mq]: kjm-rework

diff --git a/recvattach.c b/recvattach.c
--- a/recvattach.c
+++ b/recvattach.c
@@ -231,26 +231,41 @@
          _mutt_make_string (s, sizeof (s), MsgFmt, NULL, aptr->content->hdr,
                             MUTT_FORMAT_FORCESUBJ | MUTT_FORMAT_MAKEPRINT | 
MUTT_FORMAT_ARROWCURSOR);
          if (*s)
          {
            mutt_format_s (dest, destlen, prefix, s);
            break;
          }
        }
-       if (!aptr->content->filename)
+        if (!aptr->content->d_filename && !aptr->content->filename)
        {
          mutt_format_s (dest, destlen, prefix, "<no description>");
          break;
        }
       }
       else if(aptr->content->description || 
              (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)
       {
        if (aptr->content->filename && *aptr->content->filename == '/')
        {
          char path[_POSIX_PATH_MAX];
          
@@ -259,35 +274,16 @@
          mutt_format_s (dest, destlen, prefix, path);
        }
        else
          mutt_format_s (dest, destlen, prefix, NONULL 
(aptr->content->filename));
       }
       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' : ' ');
       else if(!aptr->content->deleted)
         optional = 0;
       break;
     case 'e':
       if(!optional)

Attachment: signature.asc
Description: PGP signature

Reply via email to