]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix viewing PDFs from eww with external viewers
authorLars Ingebrigtsen <larsi@gnus.org>
Fri, 11 Sep 2020 12:06:02 +0000 (14:06 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Fri, 11 Sep 2020 12:06:07 +0000 (14:06 +0200)
* lisp/net/mailcap.el (mailcap-view-mime): Most MIME viewers can't
take input on stdin (and in any case, "-" is not how many of them
designate stdin) (bug#43318).  So rewrite to put the data on a
file and feed the file name to the viewer.

lisp/net/mailcap.el

index f01a5deb7ecc33079548557a8b4d25261eca55be..e84fe5f2e0940ec4a9a652765ef9252481d64fbb 100644 (file)
@@ -1133,11 +1133,14 @@ For instance, \"foo.png\" will result in \"image/png\"."
 `mailcap--computed-mime-data' determines the method to use."
   (let ((method (mailcap-mime-info type)))
     (if (stringp method)
-       (shell-command-on-region (point-min) (point-max)
-                                ;; Use stdin as the "%s".
-                                (format method "-")
-                                (current-buffer)
-                                t)
+        (let ((file (make-temp-file "emacs-mailcap" nil
+                                    (cadr (split-string type "/")))))
+          (unwind-protect
+              (let ((coding-system-for-write 'binary))
+                (write-region (point-min) (point-max) file nil 'silent)
+                (shell-command (format method file)))
+            (when (file-exists-p file)
+              (delete-file file))))
       (funcall method))))
 
 (provide 'mailcap)