Subject: bug#24042: mudraw doesn't exist any more

From: Clément Pit--Claudel <[email-masked]>
Date: Wed, 20 Jul 2016 23:46:56 -0400

Alternatively, we could change from a program name to a function that builds a command line string; this would work with viewer/renderers that don't accept -o and -r.

On 2016-07-20 21:55, Mark Oteiza wrote:
> Mark Oteiza <[email-masked]> writes:
> 
>> Stefan Monnier <[email-masked]> writes:
>>
>>>>> Apparently mudraw has been superseded by "mutool draw".  I'm using the
>>>>> patch below to accommodate this new situation, but it's not
>>>>> quite satisfactory.
>>>> Why is it not satisfactory?  What choice do we have if `mudraw' has been
>>>> replaced?
>>>
>>> It's the string-match that's not very satisfactory.  If the "mutool"
>>> happens to have a name that doesn't match the regexp, or if some other
>>> tool (pdfdraw or mudraw) happens to match the regexp things will go wrong.
>>
>> There should likely be a doc-view-pdfdraw-options.  I remember poking
>> net-utils.el recently which has an approach like this.  May not solve
>> the problem, but at least it is exposed to the user.
> 
> diff --git a/lisp/doc-view.el b/lisp/doc-view.el
> index 223565c..e52b078 100644
> --- a/lisp/doc-view.el
> +++ b/lisp/doc-view.el
> @@ -161,10 +161,20 @@ doc-view-ghostscript-program
>  (defcustom doc-view-pdfdraw-program
>    (cond
>     ((executable-find "pdfdraw") "pdfdraw")
> +   ((executable-find "mudraw") "mudraw")
> +   ((executable-find "mutool") "mutool")
>     (t "mudraw"))
>    "Name of MuPDF's program to convert PDF files to PNG."
>    :type 'file
> -  :version "24.4")
> +  :version "25.1")
> +
> +(defcustom doc-view-pdfdraw-options
> +  (cond
> +   ((string-match-p "mutool\\'" doc-view-pdfdraw-program) (list "draw"))
> +   (t nil))
> +  "A list of options to give to `doc-view-pdfdraw-program'."
> +  :type '(repeat string)
> +  :version "25.1")
>  
>  (defcustom doc-view-pdf->png-converter-function
>    (if (executable-find doc-view-pdfdraw-program)
> @@ -960,7 +970,8 @@ doc-view-djvu->tiff-converter-ddjvu
>  (defun doc-view-pdf->png-converter-mupdf (pdf png page callback)
>    (doc-view-start-process
>     "pdf->png" doc-view-pdfdraw-program
> -   `(,(concat "-o" png)
> +   `(,@doc-view-pdfdraw-options
> +     ,(concat "-o" png)
>       ,(format "-r%d" (round doc-view-resolution))
>       ,pdf
>       ,@(if page `(,(format "%d" page))))
> 
> 
> 
>