From: dalanicolai <dalanicolai@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Emacs Devel <emacs-devel@gnu.org>
Subject: Re: [PATCH] add epub support to doc-view
Date: Tue, 11 Jan 2022 11:13:42 +0100 [thread overview]
Message-ID: <CACJP=3k6DmHAfTroBz4gxEDy5PY6G0-8HYS3J11AtS-1k0tUzA@mail.gmail.com> (raw)
In-Reply-To: <CACJP=3k_jQVv0xJ8EM-joOgdqMitkbQ_qz6RY6PdLsFQ2Pa=kA@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 10155 bytes --]
Forgot to provide the link to the (info about the) pymupdf server, in case
someone is interested...
https://github.com/vedang/pdf-tools/pull/61
On Tue, 11 Jan 2022 at 10:59, dalanicolai <dalanicolai@gmail.com> wrote:
> > (define-obsolete-variable-alias 'doc-view-unoconv-program
>>
> > - 'doc-view-odf->pdf-converter-program
>> > - "24.4")
>> > + 'doc-view-odf->pdf-converter-program
>> > + "24.4")
>>
>> Thanks. At this point, the last two args can be placed on the same
>> line ;-)
>
>
> This is also due to the auto-indent, but I will correct it manually.
>
> > (defun doc-view-new-window-function (winprops)
>> > + ;; TODO: write documentation!
>> > ;; (message "New window %s for buf %s" (car winprops)
>> (current-buffer))
>> > (cl-assert (or (eq t (car winprops))
>> > (eq (window-buffer (car winprops)) (current-buffer))))
>>
>> I plead guilty, but if you give me a more specific question, I'll find
>> it easier to answer it (even in the form of a docstring or comment).
>>
>
> This I copied from pdf-tools. However, I am planning to enter this
> documentation
> myself, while I am implementing real continuous scroll. I have got that
> working in
> pdf-tools already, but I had to disable all kinds of minor modes there. So
> I thought
> let's start with a simpler task of implementing it in doc-view, however,
> the same
> difficulty, that I encountered also in pdf-tools is that somehow
> `bookroll-mode-winprops-alist` (which is exactly the equivalent/copy of
> `bookroll-mode-winprops-alist`) obtains a value `t`. I think I've spent
> some hours
> already investigating where it obtains it (somehow I fixed it after
> debugging for
> pdf-tools for few hours, but clearly I do not understand how, and have to
> repeat the
> same things again, well I guess it is a good exercise. Anyway, in the end
> I hope to
> add some useful documentation to prevent other hackers from 'wasting'
> their time :)
> Anyway, if I can keep it like this for now, that would be great, as the
> TODO really
> jumps out font lock wise, and also I can search for it.
>
> > @@ -738,7 +740,7 @@ doc-view-kill-proc
>> > (interactive)
>> > (while (consp doc-view--current-converter-processes)
>> > (ignore-errors ;; Some entries might not be processes, and maybe
>> > - ;; some are dead already?
>> > + ;; some are dead already?
>> > (kill-process (pop doc-view--current-converter-processes))))
>> > (when doc-view--current-timer
>> > (cancel-timer doc-view--current-timer)
>>
>> Here the auto-indentation gets it wrong, sadly.
>>
>
> You mean because it aligns with the line below so that it looks like it
> belongs
> to that one? Because otherwise, I think it does not look bad.
>
> > + ((memq type '(postscript ps eps pdf epub))
>> > + (if-let (command (and (memq type '(pdf epub))
>> (executable-find "mutool")))
>> > + command
>> > + (unless (eq type 'epub)
>> > + (and doc-view-ghostscript-program
>> > + (executable-find doc-view-ghostscript-program)))))
>> > ((eq type 'odf)
>> > (and doc-view-odf->pdf-converter-program
>> > (executable-find doc-view-odf->pdf-converter-program)
>>
>> Hmm... for PDF files, this changes the previous behavior where we
>> checked for the presence of `doc-view-pdfdraw-program` rather than
>> "mutool".
>> Was there a strong reason to hardcode "mutool" here
>>
>
> Ah yes, I was aware of that, but indeed I did that consciously. I have
> very good experiences
> with (py)mupdf (I have implemented an alternative pdf-tools server using
> it, and indeed it is
> much faster than the epdfinfo server, well at least the mupdf vs poppler
> parts.
>
> really take a very quick look at the two histograms in this link
> <https://hub.alfresco.com/t5/alfresco-content-services-blog/pdf-rendering-engine-performance-and-fidelity-comparison/ba-p/287618>
> .
> So I decided this behavior really wouldn't be a problem, why not prefer
> mutool when it is
> available?
>
> Also, I think the rest of the code will still launch
>> `doc-view-pdfdraw-program` rather than `mutool`, so there's
>> something fishy.
>>
>
> That I do not understand immediately, for me the behavior is still
> somewhat opaque. But I
> will be trying to understand things further today (anyway for implementing
> the continuous scroll)
> and try to understand how it all works (and correct it here).
>
> This error message needs to be shorter. It probably shouldn't talk
>> about `mutool`. Even with this simplification I think we're going to
>> have to be creative to make it short enough to fit in a single line of
>> 80 columns. We should probably just say something like
>>
>> doc-view-pdf->png-converter-function invalid for EPub
>>
>> and then add in the docstring of `doc-view-pdf->png-converter-function`
>> a note about the fact that only `doc-view-pdf->png-converter-mupdf`
>> supports EPub.
>>
>
> That sounds good indeed. I will take care of that.
>
> Thanks, for the feedback... I will try another 'round' probably sooner
> than later :)
>
>
>
>
>
> On Tue, 11 Jan 2022 at 03:48, Stefan Monnier <monnier@iro.umontreal.ca>
> wrote:
>
>> > Here is a patch to add epub support to doc-view, via the mutool
>> > command of the mupdf library,I guess the patch needs no further
>> > explanation. I've read the info about sending patches, however,
>> > I don't understand the section about the changelog (it mentions that
>> > there is a changelog or something, but it doesn't say where). Also,
>> > the info tells us to write the commit log entries, but it does not say
>> > where to do this.Looking at the changelog files, I guess that info is
>> > just really outdated (am I right?). Anyway, the patch is in the
>> > attachment. If there is some part of the 'protocol' that I did not
>> > understand then please inform me about it.
>>
>> Looks pretty good, see below for some comments/questions.
>> Regarding the changelog, we just need you to give us something like
>>
>> doc-view.el: Add support for EPub
>>
>> <Some explanation for the general idea>
>>
>> * lisp/doc-view.el (<fun1>): <Do this>.
>> (<var2>): <Do that>.
>> ...
>>
>> * lisp/files.el (auto-mode-alist): Extend doc-view-mode-maybe
>> regexp to match `.epub` files.
>>
>> > (define-obsolete-variable-alias 'doc-view-unoconv-program
>> > - 'doc-view-odf->pdf-converter-program
>> > - "24.4")
>> > + 'doc-view-odf->pdf-converter-program
>> > + "24.4")
>>
>>
>> Thanks. At this point, the last two args can be placed on the same
>> line ;-)
>>
>> > (defun doc-view-new-window-function (winprops)
>> > + ;; TODO: write documentation!
>> > ;; (message "New window %s for buf %s" (car winprops)
>> (current-buffer))
>> > (cl-assert (or (eq t (car winprops))
>> > (eq (window-buffer (car winprops)) (current-buffer))))
>>
>> I plead guilty, but if you give me a more specific question, I'll find
>> it easier to answer it (even in the form of a docstring or comment).
>>
>> > @@ -738,7 +740,7 @@ doc-view-kill-proc
>> > (interactive)
>> > (while (consp doc-view--current-converter-processes)
>> > (ignore-errors ;; Some entries might not be processes, and maybe
>> > - ;; some are dead already?
>> > + ;; some are dead already?
>> > (kill-process (pop doc-view--current-converter-processes))))
>> > (when doc-view--current-timer
>> > (cancel-timer doc-view--current-timer)
>>
>> Here the auto-indentation gets it wrong, sadly.
>>
>> > @@ -810,11 +812,12 @@ doc-view-mode-p
>> > (executable-find doc-view-dvipdf-program))
>> > (and doc-view-dvipdfm-program
>> > (executable-find doc-view-dvipdfm-program)))))
>> > - ((memq type '(postscript ps eps pdf))
>> > - (or (and doc-view-ghostscript-program
>> > - (executable-find doc-view-ghostscript-program))
>> > - (and doc-view-pdfdraw-program
>> > - (executable-find doc-view-pdfdraw-program))))
>> > + ((memq type '(postscript ps eps pdf epub))
>> > + (if-let (command (and (memq type '(pdf epub))
>> (executable-find "mutool")))
>> > + command
>> > + (unless (eq type 'epub)
>> > + (and doc-view-ghostscript-program
>> > + (executable-find doc-view-ghostscript-program)))))
>> > ((eq type 'odf)
>> > (and doc-view-odf->pdf-converter-program
>> > (executable-find doc-view-odf->pdf-converter-program)
>>
>> Hmm... for PDF files, this changes the previous behavior where we
>> checked for the presence of `doc-view-pdfdraw-program` rather than
>> "mutool".
>> Was there a strong reason to hardcode "mutool" here?
>>
>> Depending on the reason, we may be better off splitting the epub
>> handling into its own `cond` branch.
>>
>> Also, I think the rest of the code will still launch
>> `doc-view-pdfdraw-program` rather than `mutool`, so there's
>> something fishy.
>>
>> > - ((or 'pdf 'djvu)
>> > + ((or 'pdf 'epub 'djvu)
>> > + (when (eq doc-view-doc-type 'epub)
>> > + (unless (eq doc-view-pdf->png-converter-function
>> 'doc-view-pdf->png-converter-mupdf)
>> > + (user-error "Viewing epub documents requires the`mutool'
>> command to be available,
>> > +and `doc-view-pdf->png-converter-function' variable set to
>> > +`doc-view-pdf->png-converter-mupdf'")))
>>
>> This error message needs to be shorter. It probably shouldn't talk
>> about `mutool`. Even with this simplification I think we're going to
>> have to be creative to make it short enough to fit in a single line of
>> 80 columns. We should probably just say something like
>>
>> doc-view-pdf->png-converter-function invalid for EPub
>>
>> and then add in the docstring of `doc-view-pdf->png-converter-function`
>> a note about the fact that only `doc-view-pdf->png-converter-mupdf`
>> supports EPub.
>>
>> The rest looks good.
>>
>>
>> Stefan
>>
>>
[-- Attachment #2: Type: text/html, Size: 13569 bytes --]
next prev parent reply other threads:[~2022-01-11 10:13 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-11 2:20 [PATCH] add epub support to doc-view dalanicolai
2022-01-11 2:32 ` Po Lu
2022-01-11 9:34 ` dalanicolai
2022-01-11 9:50 ` Tassilo Horn
2022-01-11 10:04 ` dalanicolai
2022-01-11 10:08 ` dalanicolai
2022-01-11 10:15 ` Robert Pluim
2022-01-11 9:59 ` Robert Pluim
2022-01-11 10:09 ` dalanicolai
2022-01-11 2:48 ` Stefan Monnier
2022-01-11 3:30 ` Stefan Kangas
2022-01-11 10:01 ` dalanicolai
2022-01-11 10:16 ` Robert Pluim
2022-01-13 9:14 ` dalanicolai
2022-01-11 9:59 ` dalanicolai
2022-01-11 10:13 ` dalanicolai [this message]
2022-01-11 14:39 ` Stefan Monnier
2022-01-13 9:25 ` dalanicolai
2022-01-14 16:15 ` dalanicolai
2022-01-14 20:02 ` dalanicolai
2022-01-26 20:28 ` dalanicolai
2022-01-27 16:05 ` Lars Ingebrigtsen
2022-01-27 21:09 ` Iñigo Serna
2022-01-28 13:47 ` Lars Ingebrigtsen
2022-01-28 19:51 ` Iñigo Serna
2022-01-29 17:07 ` dalanicolai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CACJP=3k6DmHAfTroBz4gxEDy5PY6G0-8HYS3J11AtS-1k0tUzA@mail.gmail.com' \
--to=dalanicolai@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).