]> granicus.if.org Git - neomutt/commitdiff
Implement mailcap option x-neomutt-keep
authorPietro Cerutti <gahr@gahr.ch>
Wed, 7 Nov 2018 12:59:21 +0000 (12:59 +0000)
committerRichard Russon <rich@flatcap.org>
Sat, 10 Nov 2018 13:35:40 +0000 (13:35 +0000)
The option x-neomutt-keep instructs neomutt not to remove the attachment
after the view-command has quit. This is helpful with mime types handled
by commands such as firefox, which fork before opening the attachment in
the main instance. Example:

application/pdf; evince; x-neomutt-keep;

mutt_attach.c
rfc1524.c
rfc1524.h

index 8a68f2a6d4ab9469f293cfb100291301cac1ec4d..be6566717a4ac1c778ad571f17050091f584d3c2 100644 (file)
@@ -632,15 +632,21 @@ int mutt_view_attachment(FILE *fp, struct Body *a, int flag, struct Email *e,
 
 return_error:
 
-  if (entry)
-    rfc1524_free_entry(&entry);
-  if (fp && tempfile[0])
+  if (!entry || !entry->xneomuttkeep)
   {
-    /* add temporary file to TempAttachmentsList to be deleted on exit */
-    mutt_add_temp_attachment(tempfile);
+    if (fp && tempfile[0])
+    {
+      /* add temporary file to TempAttachmentsList to be deleted on exit */
+      mutt_add_temp_attachment(tempfile);
+    }
+    else if (unlink_tempfile)
+    {
+      unlink(tempfile);
+    }
   }
-  else if (unlink_tempfile)
-    unlink(tempfile);
+
+  if (entry)
+    rfc1524_free_entry(&entry);
 
   if (pagerfile[0])
     mutt_file_unlink(pagerfile);
index 75d143a5bae0b5deefa7b13ff026077d3017b52b..42826fceabacad53cfc57e1c309193d58a64902f 100644 (file)
--- a/rfc1524.c
+++ b/rfc1524.c
@@ -340,6 +340,11 @@ static int rfc1524_mailcap_parse(struct Body *a, char *filename, char *type,
             FREE(&test_command);
           }
         }
+        else if (mutt_str_strncasecmp(field, "x-neomutt-keep", 14) == 0)
+        {
+          if (entry)
+            entry->xneomuttkeep = true;
+        }
       } /* while (ch) */
 
       if (opt == MUTT_AUTOVIEW)
@@ -377,6 +382,7 @@ static int rfc1524_mailcap_parse(struct Body *a, char *filename, char *type,
           FREE(&entry->convert);
           entry->needsterminal = false;
           entry->copiousoutput = false;
+          entry->xneomuttkeep = false;
         }
       }
     } /* while (!found && (buf = mutt_file_read_line ())) */
index b4496dc2b6bc7a6b929e94e8083a091a28180bd0..58e6ba5f934ed52ffe429a1f4b1419e8f6f0b410 100644 (file)
--- a/rfc1524.h
+++ b/rfc1524.h
@@ -46,6 +46,7 @@ struct Rfc1524MailcapEntry
   char *convert;
   bool needsterminal : 1; /**< endwin() and system */
   bool copiousoutput : 1; /**< needs pager, basically */
+  bool xneomuttkeep  : 1; /**< do not remove the file on command exit */
 };
 
 struct Rfc1524MailcapEntry *rfc1524_new_entry(void);