Re: [PATCH v3] Make buttons for attachments allow viewing as well as saving

Subject: Re: [PATCH v3] Make buttons for attachments allow viewing as well as saving

Date: Wed, 18 Jan 2012 00:40:22 +0000

To: Austin Clements

Cc: notmuch@notmuchmail.org

From: Mark Walters


> Oof, sorry.  Two more tweaks that I really should have caught in the
> previous version.  After that this gets my automatic +1.

Both fixed. I have also fixed the bug I mentioned (missing filename when
"view" falls back on save); I couldn't make it work with the
"no-default" option. However overriding mm-save-part with flet seems to
do the trick.

+(defun notmuch-show-view-part (message-id nth &optional filename content-type )
+  (notmuch-with-temp-part-buffer message-id nth
+    ;; set mm-inlined-types to nil to force an external viewer
+    (let ((handle (mm-make-handle (current-buffer) (list content-type)))
+         (mm-inlined-types nil))
+      ;; We override mm-save-part as notmuch-show-save-part is better
+      ;; since it offers the filename
+      (flet ((mm-save-part (&rest args) (ignore)))
+           (or (mm-display-part handle)
+               (notmuch-show-save-part message-id nth filename content-type))))))

Is that a reasonable solution? 

Best wishes

Mark

Thread: