unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#43318: Unable to open remote pdf directly with eww
@ 2020-09-10 19:39 Stefan Kangas
  2020-09-10 19:55 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Kangas @ 2020-09-10 19:39 UTC (permalink / raw)
  To: 43318

Steps to reproduce:

0. emacs -Q
1. M-x eww RET https://www.gnu.org/software/emacs/manual/pdf/emacs.pdf RET

Result: My external pdf reader (titled "Document Viewer", not sure what
it is, maybe some Gnome thing) opens with the message "Unable to open
file '/home/skangas/wip/emacs/-'".  It seems like it tried to open the
file "-" in the directory from which I run Emacs.

It would be useful if this would open the pdf doc-view-mode, or if the
pdf was downloaded to /tmp and opened using "Document Viewer" from there
or something.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#43318: Unable to open remote pdf directly with eww
  2020-09-10 19:39 bug#43318: Unable to open remote pdf directly with eww Stefan Kangas
@ 2020-09-10 19:55 ` Lars Ingebrigtsen
  2020-09-10 20:51   ` Lars Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2020-09-10 19:55 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 43318

Stefan Kangas <stefan@marxist.se> writes:

> 0. emacs -Q
> 1. M-x eww RET https://www.gnu.org/software/emacs/manual/pdf/emacs.pdf RET
>
> Result: My external pdf reader (titled "Document Viewer", not sure what
> it is, maybe some Gnome thing) opens with the message "Unable to open
> file '/home/skangas/wip/emacs/-'".  It seems like it tried to open the
> file "-" in the directory from which I run Emacs.
>
> It would be useful if this would open the pdf doc-view-mode, or if the
> pdf was downloaded to /tmp and opened using "Document Viewer" from there
> or something.

When I open that link in eww, I get a *eww pdf* buffer which displays
the file (after a while; that's a big pdf) using DocView mode.

So perhaps this fails if whatever tools DocView mode uses isn't
installed?  It looks like it calls...  uhm...  gs?

In that case, it should try using a different pdf viewer, but I'm not
quite sure how that's handled.  mailcap should probably be consulted?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#43318: Unable to open remote pdf directly with eww
  2020-09-10 19:55 ` Lars Ingebrigtsen
@ 2020-09-10 20:51   ` Lars Ingebrigtsen
  2020-09-10 21:25     ` Stefan Kangas
  0 siblings, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2020-09-10 20:51 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 43318

Lars Ingebrigtsen <larsi@gnus.org> writes:

> In that case, it should try using a different pdf viewer, but I'm not
> quite sure how that's handled.  mailcap should probably be consulted?

Oh, that is what it's doing:

(defun mailcap-view-mime (type)
  "View the data in the current buffer that has MIME type TYPE.
`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)
      (funcall method))))

eww puts the pdf data in a buffer and calls (for instance) "xpdf -" on
the data.

But this'll fail for most pdf viewers -- most of them don't read from
stdin, so this seems like a pretty gross hack...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#43318: Unable to open remote pdf directly with eww
  2020-09-10 20:51   ` Lars Ingebrigtsen
@ 2020-09-10 21:25     ` Stefan Kangas
  2020-09-11 12:07       ` Lars Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Kangas @ 2020-09-10 21:25 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 43318

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Lars Ingebrigtsen <larsi@gnus.org> writes:
>
>> In that case, it should try using a different pdf viewer, but I'm not
>> quite sure how that's handled.  mailcap should probably be consulted?
>
> Oh, that is what it's doing:
>
> (defun mailcap-view-mime (type)
>   "View the data in the current buffer that has MIME type TYPE.
> `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)
>       (funcall method))))
>
> eww puts the pdf data in a buffer and calls (for instance) "xpdf -" on
> the data.
>
> But this'll fail for most pdf viewers -- most of them don't read from
> stdin, so this seems like a pretty gross hack...

Sounds like a good analysis.

In my case I'm using evince, because at some point I put this in my
"~/.mailcap":

    application/pdf; evince %s

And I guess evince doesn't read from stdin, as you say...





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#43318: Unable to open remote pdf directly with eww
  2020-09-10 21:25     ` Stefan Kangas
@ 2020-09-11 12:07       ` Lars Ingebrigtsen
  2020-10-02 14:31         ` Stefan Kangas
  0 siblings, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2020-09-11 12:07 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 43318

Stefan Kangas <stefan@marxist.se> writes:

> In my case I'm using evince, because at some point I put this in my
> "~/.mailcap":
>
>     application/pdf; evince %s
>
> And I guess evince doesn't read from stdin, as you say...

I've now fixed this on the trunk to start the external viewer the
traditional way.  It starts it synchronously, though, which isn't ideal,
but having the deletion triggered from a process filter, for instance,
will leave the temporary file there upon crashes...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#43318: Unable to open remote pdf directly with eww
  2020-09-11 12:07       ` Lars Ingebrigtsen
@ 2020-10-02 14:31         ` Stefan Kangas
  2020-10-02 14:32           ` Lars Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Kangas @ 2020-10-02 14:31 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 43318

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Stefan Kangas <stefan@marxist.se> writes:
>
>> In my case I'm using evince, because at some point I put this in my
>> "~/.mailcap":
>>
>>     application/pdf; evince %s
>>
>> And I guess evince doesn't read from stdin, as you say...
>
> I've now fixed this on the trunk to start the external viewer the
> traditional way.  It starts it synchronously, though, which isn't ideal,
> but having the deletion triggered from a process filter, for instance,
> will leave the temporary file there upon crashes...

I've now tested it and I can confirm that your fix works here.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#43318: Unable to open remote pdf directly with eww
  2020-10-02 14:31         ` Stefan Kangas
@ 2020-10-02 14:32           ` Lars Ingebrigtsen
  0 siblings, 0 replies; 7+ messages in thread
From: Lars Ingebrigtsen @ 2020-10-02 14:32 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 43318

Stefan Kangas <stefan@marxist.se> writes:

> I've now tested it and I can confirm that your fix works here.

Thanks!

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-10-02 14:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-10 19:39 bug#43318: Unable to open remote pdf directly with eww Stefan Kangas
2020-09-10 19:55 ` Lars Ingebrigtsen
2020-09-10 20:51   ` Lars Ingebrigtsen
2020-09-10 21:25     ` Stefan Kangas
2020-09-11 12:07       ` Lars Ingebrigtsen
2020-10-02 14:31         ` Stefan Kangas
2020-10-02 14:32           ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).