bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#44338: 27.1; EWW can't download and view pdf


From: Basil L. Contovounesios
Subject: bug#44338: 27.1; EWW can't download and view pdf
Date: Thu, 05 Nov 2020 21:25:15 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

tags 44338 fixed
close 44338 28.1
quit

Lars Ingebrigtsen <larsi@gnus.org> writes:

> "Basil L. Contovounesios" <contovob@tcd.ie> writes:
>
>> In other words, can we remove the binding altogether from
>> eww-display-pdf and make the *eww pdf* buffer unibyte, as Stefan
>> suggested?
>
> Yes, this is the correct fix.

Thanks, done.

Fix coding system in eww-display-pdf
4610241a9b 2020-11-05 21:06:39 +0000
https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=4610241a9b3fbddd1f0973bf49f7008ed09ab955

I'm therefore marking this bug as fixed in 28.1.

Nicholas, here's the cumulative change to the function eww-display-pdf,
in case you want to patch/advise yours on Emacs 27.1:

diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index d6f850ca3b..43405fbd9c 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -667,14 +811,19 @@ eww-display-image
 
 (declare-function mailcap-view-mime "mailcap" (type))
 (defun eww-display-pdf ()
-  (let ((data (buffer-substring (point) (point-max))))
-    (pop-to-buffer-same-window (get-buffer-create "*eww pdf*"))
-    (let ((coding-system-for-write 'raw-text)
-         (inhibit-read-only t))
-      (erase-buffer)
-      (insert data)
-      (mailcap-view-mime "application/pdf")))
-  (goto-char (point-min)))
+  (let ((buf (current-buffer))
+        (pos (point)))
+    (with-current-buffer (get-buffer-create "*eww pdf*")
+      (let ((inhibit-read-only t))
+        (erase-buffer)
+        (set-buffer-multibyte nil)
+        (insert-buffer-substring buf pos)
+        (mailcap-view-mime "application/pdf"))
+      (if (zerop (buffer-size))
+          ;; Buffer contents passed to shell command via temporary file.
+          (kill-buffer)
+        (goto-char (point-min))
+        (pop-to-buffer-same-window (current-buffer))))))
 
 (defun eww-setup-buffer ()
   (when (or (plist-get eww-data :url)
-- 
Basil

reply via email to

[Prev in Thread] Current Thread [Next in Thread]