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: Eli Zaretskii
Subject: bug#44338: 27.1; EWW can't download and view pdf
Date: Wed, 04 Nov 2020 17:07:42 +0200

> From: Nicholas Harrison <nicholasharrison222@gmail.com>
> Date: Tue, 3 Nov 2020 16:52:40 -0700
> Cc: 44338@debbugs.gnu.org
> 
> This can be (partially) corrected by running the following code before the 
> steps 2 and 3:
> (add-to-list 'mailcap-user-mime-data
>              '((type . "application/pdf")
>                (viewer . doc-view-mode)))
> 
> This chooses a view mode for the pdf but that brings the second problem. This 
> selects the default encoding
> of raw-text and the conversion fails:

You say it selects raw-text, but the screenshot you sent clearly shows
that Emacs was trying to use iso-latin-1-dos.  In which case the
failure is easily understandable, but I don't immediately see where
did that value come from (it's most probably the default value of
buffer-file-coding-system for you, but since eww-display-pdf binds
coding-system-for-write, the question is why that value isn't being
used).  Could you perhaps produce a backtrace from that situation?
For example, like this:

  M-: (debug-on-entry 'select-safe-coding-system) RET

and then repeat the recipe.

In any case, this isn't right:

  (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)))

We should use 'raw-text-unix here, since the buffer contents is a
stream of raw bytes.





reply via email to

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