From a34a80a878f37832cc5e59f2c26ea1779eca5cf8 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Fri, 11 Sep 2020 14:06:02 +0200 Subject: [PATCH] Fix viewing PDFs from eww with external viewers * 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 | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lisp/net/mailcap.el b/lisp/net/mailcap.el index f01a5deb7ec..e84fe5f2e09 100644 --- a/lisp/net/mailcap.el +++ b/lisp/net/mailcap.el @@ -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) -- 2.39.5