From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Elias Pipping Newsgroups: gmane.emacs.bugs Subject: bug#13164: [PATCH] View DjVu documents through doc-view-mode Date: Thu, 10 Jan 2013 01:15:28 +0100 Message-ID: <8738y999lr.fsf@lavabit.com> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1357777020 19680 80.91.229.3 (10 Jan 2013 00:17:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 10 Jan 2013 00:17:00 +0000 (UTC) Cc: 13164@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jan 10 01:17:17 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Tt5pX-0000HG-KX for geb-bug-gnu-emacs@m.gmane.org; Thu, 10 Jan 2013 01:17:11 +0100 Original-Received: from localhost ([::1]:49699 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tt5pH-0003wt-DJ for geb-bug-gnu-emacs@m.gmane.org; Wed, 09 Jan 2013 19:16:55 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:59341) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tt5pD-0003wn-FZ for bug-gnu-emacs@gnu.org; Wed, 09 Jan 2013 19:16:52 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tt5pC-0002pe-0P for bug-gnu-emacs@gnu.org; Wed, 09 Jan 2013 19:16:51 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:45946) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tt5pB-0002pa-S2 for bug-gnu-emacs@gnu.org; Wed, 09 Jan 2013 19:16:49 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1Tt5pN-0008TB-Nu for bug-gnu-emacs@gnu.org; Wed, 09 Jan 2013 19:17:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Elias Pipping Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 10 Jan 2013 00:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13164 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 13164-submit@debbugs.gnu.org id=B13164.135777698132501 (code B ref 13164); Thu, 10 Jan 2013 00:17:01 +0000 Original-Received: (at 13164) by debbugs.gnu.org; 10 Jan 2013 00:16:21 +0000 Original-Received: from localhost ([127.0.0.1]:59187 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tt5of-0008S7-W9 for submit@debbugs.gnu.org; Wed, 09 Jan 2013 19:16:20 -0500 Original-Received: from karen.lavabit.com ([72.249.41.33]:34675) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tt5oL-0008RH-7H for 13164@debbugs.gnu.org; Wed, 09 Jan 2013 19:16:00 -0500 Original-Received: from c.earth.lavabit.com (c.earth.lavabit.com [192.168.111.12]) by karen.lavabit.com (Postfix) with ESMTP id 0D11611BC6C; Wed, 9 Jan 2013 18:15:44 -0600 (CST) Original-Received: from bogus (e178038187.adsl.alicedsl.de [85.178.38.187]) by lavabit.com with ESMTP id W704MIR22VQC; Wed, 09 Jan 2013 18:15:44 -0600 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=lavabit; d=lavabit.com; b=wkM9GP5Mf5Skiq8xZAt7yd4rKSZyADBKETFhHWQWoTnF6xdyw277birRacKQhBpWJB6IM0RIS2q3qVUrT5kCy4D24nSLn/gZbC6Fhnj9nSs3YpHD0jaQHGsnmvdeJZbaINHD0vCn8H8j5Ug2YpRoxURTuxkO+ELBySCmzRm3w28=; h=From:To:Cc:Subject:References:Date:In-Reply-To:Message-ID:User-Agent:MIME-Version:Content-Type; In-Reply-To: (Stefan Monnier's message of "Wed, 09 Jan 2013 15:28:11 -0500") User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.2.91 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 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.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:69550 Archived-At: --=-=-= Content-Type: text/plain Stefan Monnier writes: >> I sent a patch to this list last year that made it possible to use >> mupdf's "mudraw" instead of ghostscript's "gs" to convert pdf documents >> into png files within doc-view-mode. > > Thanks, I've just installed your mupdf patch with a few cosmetic > changes, thank you. > The djvu patch is still pending, I see you've pushed the djvu patch as well. Thank you; also for the modifications you've made. I've attached three more tiny patches. Best regards, Elias Pipping --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Enable-doc-view-for-djvu-files.patch >From 887b136fa79c81422c3fddc858e446f26ac71ab7 Mon Sep 17 00:00:00 2001 From: Elias Pipping Date: Thu, 10 Jan 2013 00:56:50 +0100 Subject: [PATCH 1/3] Enable doc-view for djvu files --- lisp/files.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/files.el b/lisp/files.el index ca5a415..9fea670 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -2357,7 +2357,7 @@ ARC\\|ZIP\\|LZH\\|LHA\\|ZOO\\|[JEW]AR\\|XPI\\|RAR\\|7Z\\)\\'" . archive-mode) ("\\.\\(diffs?\\|patch\\|rej\\)\\'" . diff-mode) ("\\.\\(dif\\|pat\\)\\'" . diff-mode) ; for MSDOG ("\\.[eE]?[pP][sS]\\'" . ps-mode) - ("\\.\\(?:PDF\\|DVI\\|OD[FGPST]\\|DOCX?\\|XLSX?\\|PPTX?\\|pdf\\|dvi\\|od[fgpst]\\|docx?\\|xlsx?\\|pptx?\\)\\'" . doc-view-mode-maybe) + ("\\.\\(?:PDF\\|DVI\\|DJVU\\|OD[FGPST]\\|DOCX?\\|XLSX?\\|PPTX?\\|pdf\\|djvu\\|dvi\\|od[fgpst]\\|docx?\\|xlsx?\\|pptx?\\)\\'" . doc-view-mode-maybe) ("configure\\.\\(ac\\|in\\)\\'" . autoconf-mode) ("\\.s\\(v\\|iv\\|ieve\\)\\'" . sieve-mode) ("BROWSE\\'" . ebrowse-tree-mode) -- 1.8.1 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0002-single-page-converter-need-not-be-passed.patch >From a8a298ab5b6a2c12e7cca16af81ba76fd54d1c9a Mon Sep 17 00:00:00 2001 From: Elias Pipping Date: Thu, 10 Jan 2013 00:59:16 +0100 Subject: [PATCH 2/3] single-page-converter need not be passed --- lisp/doc-view.el | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lisp/doc-view.el b/lisp/doc-view.el index 0658a11..5f2d70d 100644 --- a/lisp/doc-view.el +++ b/lisp/doc-view.el @@ -970,7 +970,7 @@ Call CALLBACK with no arguments when done." (declare-function clear-image-cache "image.c" (&optional filter)) -(defun doc-view-document->png (pdf png pages single-page-converter) +(defun doc-view-document->png (pdf png pages) ;; FIXME: Fix docstring. "Convert a PDF file to PNG asynchronously. Start by converting PAGES, and then the rest." @@ -981,7 +981,7 @@ Start by converting PAGES, and then the rest." ;; a single page anyway, and of the remaining 1%, few cases will have ;; consecutive pages, it's not worth the trouble. (let ((rest (cdr pages))) - (funcall single-page-converter + (funcall doc-view-single-page-converter-function pdf (format png (car pages)) (car pages) (lambda () (if rest @@ -1095,12 +1095,10 @@ Those files are saved in the directory given by the function (`pdf (let ((pages (doc-view-active-pages))) ;; Convert PDF to PNG images starting with the active pages. - (doc-view-document->png doc-view-buffer-file-name png-file pages - 'doc-view-pdf->png-1))) + (doc-view-document->png doc-view-buffer-file-name png-file pages))) (`djvu (let ((pages (doc-view-active-pages))) - (doc-view-document->png doc-view-buffer-file-name png-file pages - 'doc-view-djvu->png-1))) + (doc-view-document->png doc-view-buffer-file-name png-file pages))) (_ ;; Convert to PNG images. (doc-view-pdf/ps->png doc-view-buffer-file-name png-file))))) -- 1.8.1 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0003-Detect-properly-if-PDFs-can-be-handled.patch >From 31244c43ecf24945db95c823c020eccb68d3ef1d Mon Sep 17 00:00:00 2001 From: Elias Pipping Date: Thu, 10 Jan 2013 01:12:45 +0100 Subject: [PATCH 3/3] Detect properly if PDFs can be handled --- lisp/doc-view.el | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lisp/doc-view.el b/lisp/doc-view.el index 5f2d70d..8065b3e 100644 --- a/lisp/doc-view.el +++ b/lisp/doc-view.el @@ -708,11 +708,18 @@ OpenDocument format)." (executable-find doc-view-dvipdf-program)) (and doc-view-dvipdfm-program (executable-find doc-view-dvipdfm-program))))) - ((or (eq type 'postscript) (eq type 'ps) (eq type 'eps) - (eq type 'pdf)) - ;; FIXME: allow mupdf here + ((or (eq type 'postscript) (eq type 'ps) (eq type 'eps)) (and doc-view-ghostscript-program (executable-find doc-view-ghostscript-program))) + ((eq type 'pdf) + (pcase doc-view-pdf->png-converter-function + (`doc-view-pdf->png-converter-ghostscript + (and doc-view-ghostscript-program + (executable-find doc-view-ghostscript-program))) + (`doc-view-pdf->png-converter-mupdf + (and doc-view-pdfdraw-program + (executable-find doc-view-pdfdraw-program))) + (_ t))) ;; Assume the user knows what he/she is doing ((eq type 'odf) (and doc-view-unoconv-program (executable-find doc-view-unoconv-program) -- 1.8.1 --=-=-=--