From: Kevin McCarthy Date: Tue, 8 Nov 2016 02:10:27 +0000 (-0800) Subject: Chain %d->%F->%f in the attachment menu. X-Git-Tag: neomutt-20170225~32^2~82 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=146d4a145b2aa3a2c39e1851e184dbea27aa6f96;p=neomutt 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. --- diff --git a/recvattach.c b/recvattach.c index 9693827e0..562c6b553 100644 --- a/recvattach.c +++ b/recvattach.c @@ -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, ""); 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' : ' ');