From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Nicholas Harrison Newsgroups: gmane.emacs.bugs Subject: bug#44338: 27.1; EWW can't download and view pdf Date: Wed, 4 Nov 2020 16:43:13 -0700 Message-ID: References: <878sbmo6i0.fsf@tcd.ie> <83tuu5b1oh.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000008e9e5c05b3508ba8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16966"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "Basil L. Contovounesios" , 44338@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Nov 05 00:44:10 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kaSRm-0004It-2p for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 05 Nov 2020 00:44:10 +0100 Original-Received: from localhost ([::1]:45696 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaSRk-0006cX-Mw for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 04 Nov 2020 18:44:08 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52994) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaSRe-0006cP-5Q for bug-gnu-emacs@gnu.org; Wed, 04 Nov 2020 18:44:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:39447) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kaSRd-0005hm-SY for bug-gnu-emacs@gnu.org; Wed, 04 Nov 2020 18:44:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kaSRd-00034W-OW for bug-gnu-emacs@gnu.org; Wed, 04 Nov 2020 18:44:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Nicholas Harrison Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 04 Nov 2020 23:44:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44338 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 44338-submit@debbugs.gnu.org id=B44338.160453341211761 (code B ref 44338); Wed, 04 Nov 2020 23:44:01 +0000 Original-Received: (at 44338) by debbugs.gnu.org; 4 Nov 2020 23:43:32 +0000 Original-Received: from localhost ([127.0.0.1]:50993 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kaSR9-00033c-D5 for submit@debbugs.gnu.org; Wed, 04 Nov 2020 18:43:31 -0500 Original-Received: from mail-yb1-f180.google.com ([209.85.219.180]:43862) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kaSR7-00033P-8N for 44338@debbugs.gnu.org; Wed, 04 Nov 2020 18:43:29 -0500 Original-Received: by mail-yb1-f180.google.com with SMTP id c18so363065ybj.10 for <44338@debbugs.gnu.org>; Wed, 04 Nov 2020 15:43:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=jyU4BZlp8xbFA0gIAYsi5mDrqlMs/WfRH7/MdMiKzfs=; b=GAGx87V48sSx2f9M61c0KKT0ia8tn2bfz50/U0Lip+GM6nRl4gkslyG7yx7i27S6VT YXBaQDJiixm1z1xg02wM0SNFgzLMUjgOCLA2PHgMpMsCA4cNScf76lwKGqDmS+EpSODE vWR11U4meNZeFLkgHxOEqEWqKbPQVCqs3uhkFyuxDwzNNy8z53sfgQbb/jNX0xWutUJO yHHHT6uxeVDE5FJLWl9AZHUNgnPyLg7zDir2b/hZYaqlGlvbHXfbrWer/7e51UbAB7mv 8x5SZeUHcyHgw3nXR72V2akUG/gGFEYjIrbBgutwVrm77ODXogebXGKLc8/1wlMk7n8R TlFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=jyU4BZlp8xbFA0gIAYsi5mDrqlMs/WfRH7/MdMiKzfs=; b=MyX3aStOnqVB8z4n2syeAlIjW90atw81Xw5t48bitzLb6VvF1W0EUuv5RiG8rf2StL pAdBas5r8tMuBo14ANe8uwsgQuKdBm9AaCvTNf65usj6EyWAyhiEk0FfdZU+1IaOGOa1 cMTgu+y/nlOFcb9YxNn+VN+NeVgNKPKkB6qQfRiVWbeIkTcVAeaAUMnxza/538aeI8z4 EVRygcm4/pACujlQFYTXlA1XSOaJFOVgQ5yubx16SoZffSAq/XAXBWhbDYST0+RPx7qz ry1mELGhFgH1Zrz+ThBh4tfM9TvkTIUdQumlOuHOLkrOZ6CmSMP4V/prSF006gEdT2LO vu9g== X-Gm-Message-State: AOAM533hfcoS9QzO1yEgsu1E9uHQQurd6YWFQ9OcObb1Dd6Owu4f1DZ/ 36nzfxyU/1ig67IEjy6RQIDGxdrmStd1ACUXszs= X-Google-Smtp-Source: ABdhPJxn0iPfBwa78Vz7c5iv+qBimjf0H24909aK1s5FFLD7bQJ1bhvGftKHXx2FxKikIHEbOmtmsRaIJvPhMO6w/lk= X-Received: by 2002:a25:d9cf:: with SMTP id q198mr392234ybg.182.1604533403687; Wed, 04 Nov 2020 15:43:23 -0800 (PST) In-Reply-To: <83tuu5b1oh.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:192694 Archived-At: --0000000000008e9e5c05b3508ba8 Content-Type: text/plain; charset="UTF-8" Not sure if this is much help, but here is the backtrace given when I do the following steps: 1. emacs -Q 2. M-: (debug-on-entry 'select-safe-coding-system) RET 3. M-x eww RET https://www.gnu.org/software/emacs/manual/pdf/emacs-xtra.pdf RET (no backtrace here) 4. M-x doc-view-mode RET Debugger entered--entering a function: * select-safe-coding-system(1 381654 iso-latin-1-dos nil "c:/Users/nicho/AppData/Local/Temp/docview1001/!eww pdf!") write-region(nil nil "c:/Users/nicho/AppData/Local/Temp/docview1001/!eww pdf!") doc-view-mode() funcall-interactively(doc-view-mode) call-interactively(doc-view-mode record nil) command-execute(doc-view-mode record) execute-extended-command(nil "doc-view-mode" "doc-view-mo") funcall-interactively(execute-extended-command nil "doc-view-mode" "doc-view-mo") call-interactively(execute-extended-command nil nil) command-execute(execute-extended-command) 5. ESC ESC ESC 6. RET (it asks to choose an encoding, chose default raw-text) Debugger entered--returning value: raw-text select-safe-coding-system(1 381654 iso-latin-1-dos nil "c:/Users/nicho/AppData/Local/Temp/docview1001/!eww...") write-region(nil nil "c:/Users/nicho/AppData/Local/Temp/docview1001/!eww...") doc-view-mode() funcall-interactively(doc-view-mode) call-interactively(doc-view-mode record nil) command-execute(doc-view-mode record) execute-extended-command(nil "doc-view-mode" "doc-view-mo") funcall-interactively(execute-extended-command nil "doc-view-mode" "doc-view-mo") call-interactively(execute-extended-command nil nil) command-execute(execute-extended-command) Debugger entered--entering a function: * select-safe-coding-system(1 383892 no-conversion nil) md5(#) doc-view--current-cache-dir() doc-view-already-converted-p() doc-view-initiate-display() doc-view-mode() funcall-interactively(doc-view-mode) call-interactively(doc-view-mode record nil) command-execute(doc-view-mode record) execute-extended-command(nil "doc-view-mode" "doc-view-mo") funcall-interactively(execute-extended-command nil "doc-view-mode" "doc-view-mo") call-interactively(execute-extended-command nil nil) command-execute(execute-extended-command) Debugger entered--returning value: no-conversion select-safe-coding-system(1 383892 no-conversion nil) md5(#) doc-view--current-cache-dir() doc-view-already-converted-p() doc-view-initiate-display() doc-view-mode() funcall-interactively(doc-view-mode) call-interactively(doc-view-mode record nil) command-execute(doc-view-mode record) execute-extended-command(nil "doc-view-mode" "doc-view-mo") funcall-interactively(execute-extended-command nil "doc-view-mode" "doc-view-mo") call-interactively(execute-extended-command nil nil) command-execute(execute-extended-command) Debugger entered--entering a function: * select-safe-coding-system("100" nil prefer-utf-8 nil "c:/Users/nicho/AppData/Local/Temp/docview1001/!eww pdf!-2072e1249b26ee28e656f1a01f0cb4a9/resolution.el") write-region("100" nil "c:/Users/nicho/AppData/Local/Temp/docview1001/!eww pdf!-2072e1249b26ee28e656f1a01f0cb4a9/resolution...." nil silently) #f(compiled-function () #)() doc-view-sentinel(#png> "finished\n") Debugger entered--returning value: prefer-utf-8-dos select-safe-coding-system("100" nil prefer-utf-8 nil "c:/Users/nicho/AppData/Local/Temp/docview1001/!eww...") write-region("100" nil "c:/Users/nicho/AppData/Local/Temp/docview1001/!eww..." nil silently) #f(compiled-function () #)() doc-view-sentinel(#png> "finished\n") Debugger entered--returning value: prefer-utf-8-dos select-safe-coding-system("100" nil prefer-utf-8 nil "c:/Users/nicho/AppData/Local/Temp/docview1001/!eww...") write-region("100" nil "c:/Users/nicho/AppData/Local/Temp/docview1001/!eww..." nil silently) #f(compiled-function () #)() doc-view-sentinel(#png> "finished\n") Let me know if I was supposed to do something differently. Nicholas On Wed, Nov 4, 2020 at 8:07 AM Eli Zaretskii wrote: > > From: Nicholas Harrison > > 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. > --0000000000008e9e5c05b3508ba8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Not sure if this is much help, but here i= s the backtrace given when I do the following steps:
=
1. emacs -Q
2. M-: (debug-on-entry 'select-saf= e-coding-system) RET
(no backtrace here)
4. M-x doc-view-mode RET

Debugger entered-= -entering a function:
* select-safe-coding-system(1 381654 iso-latin-1-d= os nil "c:/Users/nicho/AppData/Local/Temp/docview1001/!eww pdf!")=
=C2=A0 write-region(nil nil "c:/Users/nicho/AppData/Local/Temp/doc= view1001/!eww pdf!")
=C2=A0 doc-view-mode()
=C2=A0 funcall-inter= actively(doc-view-mode)
=C2=A0 call-interactively(doc-view-mode record n= il)
=C2=A0 command-execute(doc-view-mode record)
=C2=A0 execute-exten= ded-command(nil "doc-view-mode" "doc-view-mo")
=C2= =A0 funcall-interactively(execute-extended-command nil "doc-view-mode&= quot; "doc-view-mo")
=C2=A0 call-interactively(execute-extende= d-command nil nil)
=C2=A0 command-execute(execute-extended-command)
<= /div>

5. ESC ESC ESC
6. RET (it asks to choose= =C2=A0an encoding, chose default raw-text)

Debugge= r entered--returning value: raw-text
=C2=A0 select-safe-coding-system(1 = 381654 iso-latin-1-dos nil "c:/Users/nicho/AppData/Local/Temp/docview1= 001/!eww...")
=C2=A0 write-region(nil nil "c:/Users/nicho/AppD= ata/Local/Temp/docview1001/!eww...")
=C2=A0 doc-view-mode()
=C2= =A0 funcall-interactively(doc-view-mode)
=C2=A0 call-interactively(doc-v= iew-mode record nil)
=C2=A0 command-execute(doc-view-mode record)
=C2= =A0 execute-extended-command(nil "doc-view-mode" "doc-view-m= o")
=C2=A0 funcall-interactively(execute-extended-command nil "= ;doc-view-mode" "doc-view-mo")
=C2=A0 call-interactively(= execute-extended-command nil nil)
=C2=A0 command-execute(execute-extende= d-command)

Debugger entered--entering a functi= on:
* select-safe-coding-system(1 383892 no-conversion nil)
=C2=A0 md= 5(#<buffer =C2=A0*temp*>)
=C2=A0 doc-view--current-cache-dir()
= =C2=A0 doc-view-already-converted-p()
=C2=A0 doc-view-initiate-display()=
=C2=A0 doc-view-mode()
=C2=A0 funcall-interactively(doc-view-mode)=C2=A0 call-interactively(doc-view-mode record nil)
=C2=A0 command-exe= cute(doc-view-mode record)
=C2=A0 execute-extended-command(nil "doc= -view-mode" "doc-view-mo")
=C2=A0 funcall-interactively(e= xecute-extended-command nil "doc-view-mode" "doc-view-mo&quo= t;)
=C2=A0 call-interactively(execute-extended-command nil nil)
=C2= =A0 command-execute(execute-extended-command)

= Debugger entered--returning value: no-conversion
=C2=A0 select-safe-codi= ng-system(1 383892 no-conversion nil)
=C2=A0 md5(#<buffer =C2=A0*temp= *>)
=C2=A0 doc-view--current-cache-dir()
=C2=A0 doc-view-already-c= onverted-p()
=C2=A0 doc-view-initiate-display()
=C2=A0 doc-view-mode(= )
=C2=A0 funcall-interactively(doc-view-mode)
=C2=A0 call-interactive= ly(doc-view-mode record nil)
=C2=A0 command-execute(doc-view-mode record= )
=C2=A0 execute-extended-command(nil "doc-view-mode" "do= c-view-mo")
=C2=A0 funcall-interactively(execute-extended-command n= il "doc-view-mode" "doc-view-mo")
=C2=A0 call-intera= ctively(execute-extended-command nil nil)
=C2=A0 command-execute(execute= -extended-command)

Debugger entered--entering = a function:
* select-safe-coding-system("100" nil prefer-utf-8= nil "c:/Users/nicho/AppData/Local/Temp/docview1001/!eww pdf!-2072e124= 9b26ee28e656f1a01f0cb4a9/resolution.el")
=C2=A0 write-region("= 100" nil "c:/Users/nicho/AppData/Local/Temp/docview1001/!eww pdf!= -2072e1249b26ee28e656f1a01f0cb4a9/resolution...." nil silently)
=C2= =A0 #f(compiled-function () #<bytecode 0x42abe9>)()
=C2=A0 doc-vie= w-sentinel(#<process pdf/ps->png> "finished\n")

Debugger entered--returning value: prefer-utf-8-dos=C2=A0 select-safe-coding-system("100" nil prefer-utf-8 nil &quo= t;c:/Users/nicho/AppData/Local/Temp/docview1001/!eww...")
=C2=A0 wr= ite-region("100" nil "c:/Users/nicho/AppData/Local/Temp/docv= iew1001/!eww..." nil silently)
=C2=A0 #f(compiled-function () #<= bytecode 0x42abe9>)()
=C2=A0 doc-view-sentinel(#<process pdf/ps-&g= t;png> "finished\n")

Debugger ent= ered--returning value: prefer-utf-8-dos
=C2=A0 select-safe-coding-system= ("100" nil prefer-utf-8 nil "c:/Users/nicho/AppData/Local/Te= mp/docview1001/!eww...")
=C2=A0 write-region("100" nil &q= uot;c:/Users/nicho/AppData/Local/Temp/docview1001/!eww..." nil silentl= y)
=C2=A0 #f(compiled-function () #<bytecode 0x42abe9>)()
=C2= =A0 doc-view-sentinel(#<process pdf/ps->png> "finished\n"= ;)

=C2=A0 Let me know if I was supposed to do = something differently.

Nicholas=C2=A0
On Wed, N= ov 4, 2020 at 8:07 AM Eli Zaretskii <eli= z@gnu.org> wrote:
> From: Nicholas Harrison <nicholasharrison222@gmail.com> > Date: Tue, 3 Nov 2020 16:52:40 -0700
> Cc: 44338@d= ebbugs.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
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 '((type . "ap= plication/pdf")
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (viewer . doc-v= iew-mode)))
>
> This chooses a view mode for the pdf but that brings the second proble= m. 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.=C2=A0 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).=C2=A0 Could you perhaps produce a backtrace from that situation?
For example, like this:

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

and then repeat the recipe.

In any case, this isn't right:

=C2=A0 (defun eww-display-pdf ()
=C2=A0 =C2=A0 (let ((data (buffer-substring (point) (point-max))))
=C2=A0 =C2=A0 =C2=A0 (pop-to-buffer-same-window (get-buffer-create "*e= ww pdf*"))
=C2=A0 =C2=A0 =C2=A0 (let ((coding-system-for-write 'raw-text)=C2=A0 &l= t;<<<<<<<<<<<<<<<<<<&= lt;<<
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (inhibit-read-only t))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (erase-buffer)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (insert data)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (mailcap-view-mime "application/pdf")= ))
=C2=A0 =C2=A0 (goto-char (point-min)))

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