From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] add epub support to doc-view Date: Mon, 10 Jan 2022 21:48:16 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30282"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: Emacs Devel To: dalanicolai Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Jan 11 03:52:43 2022 Return-path: Envelope-to: ged-emacs-devel@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 1n77H8-0007hb-Ow for ged-emacs-devel@m.gmane-mx.org; Tue, 11 Jan 2022 03:52:43 +0100 Original-Received: from localhost ([::1]:33866 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n77H7-0003WY-HS for ged-emacs-devel@m.gmane-mx.org; Mon, 10 Jan 2022 21:52:41 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:54042) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n77D0-0007Nj-PG for emacs-devel@gnu.org; Mon, 10 Jan 2022 21:48:28 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:40423) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n77Cy-0003bU-8E for emacs-devel@gnu.org; Mon, 10 Jan 2022 21:48:26 -0500 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 1089F442287; Mon, 10 Jan 2022 21:48:20 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 31BEB44227B; Mon, 10 Jan 2022 21:48:18 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1641869298; bh=Jzz4601zz4b1VRT6pMXmm7W9C8SfcHq+nrDyQuGn5Fg=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=L3f4SpUR+YpzgIsYyaAPB5uRJsBk/9bhuLVwWYWioEpnj5ZsJPUyqyF8x4bBSxw5l 4Lh7bTJMKCSFSPcZYiejUsCa1/IZLtk0pWGbRVEahOmFoJpSk+mv/Y/IyDZKUiWizn S7ZaUkh97v9GhF/39lZ+CyWcQFw9KdLuilWLv/0sBLHmYICGGC+dj0jmu2YNDNH1cq MMR+ipD1OIxridgI0f8Ts1wVKgF2CyDlr9D4btJ0OuOz9DT2uIfjnJH65ybuZelg2q j1Eb+ZSAT9wDLsvq1Fg59YvYPOmnQF/kW2xIoefa5FgZwTGGkSDd+3u99f11wtOvoW lv0ey8b8FJzOw== Original-Received: from ceviche (unknown [216.154.30.173]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id EEFC512041E; Mon, 10 Jan 2022 21:48:17 -0500 (EST) In-Reply-To: (dalanicolai@gmail.com's message of "Tue, 11 Jan 2022 03:20:19 +0100") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:284566 Archived-At: > 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 * lisp/doc-view.el (): . (): . ... * 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