unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: dalanicolai <dalanicolai@gmail.com>
Cc: Emacs Devel <emacs-devel@gnu.org>
Subject: Re: [PATCH] add epub support to doc-view
Date: Mon, 10 Jan 2022 21:48:16 -0500	[thread overview]
Message-ID: <jwvee5f2e6t.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <CACJP=3kaQyqYdwM5RiLn3+pdyvtfS78oayAaOKHTa8HEZwV+tg@mail.gmail.com> (dalanicolai@gmail.com's message of "Tue, 11 Jan 2022 03:20:19 +0100")

> 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




  parent reply	other threads:[~2022-01-11  2:48 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 [this message]
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
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=jwvee5f2e6t.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=dalanicolai@gmail.com \
    --cc=emacs-devel@gnu.org \
    /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).