Subject: bug#36357: Wrong Ghostscript program name on MS Win

From: Arash Esbati <[email-masked]>
Date: Mon, 20 Apr 2020 22:57:40 +0200

Sebastian Urban <[email-masked]> writes:

> Alright, 25 days have passed, and decision (preferably deed) for this
> simple bug should be made.
>
> Meanwhile I read initial e-mail for this bug and I found a quote:
>> Or as S. Monnier wrote: "(...) the default could simply
>> (executable-find "gs") and (executable-find "gswin32c") and use
>> whichever was found (...)".
> Could this "executable-find" help in this case?
>
> If not, and the condition based on "system-configration" will cause
> more problems than it'll solve, then a simple change to "gswin64c"
> should still be better option than leaving "gswin32c".

I don't use doc-view, so I can't really tell, but preview.el (part of
AUCTeX) uses "executable-find".  Applied to
`doc-view-ghostscript-program', it could look like this:

--8<---------------cut here---------------start------------->8---
(defcustom doc-view-ghostscript-program
  (or
   ;; The GS wrapper coming with TeX Live
   (file-name-base (executable-find "rungs"))
   ;; The MikTeX builtin GS
   (let ((gs (executable-find "mgs")))
     ;; Check if mgs is functional for external non-MikTeX apps.
     ;; See http://blog.miktex.org/post/2005/04/07/Starting-mgsexe-at-the-DOS-Prompt.aspx
     ;; N.B.: Link doesn't work no more!
     (when (and gs (= 0 (shell-command
			 (concat (shell-quote-argument gs)
				 " -q -dNODISPLAY -c quit"))))
       (file-name-base gs)))
   ;; Windows Ghostscript
   (file-name-base (executable-find "gswin64c.exe"))
   (file-name-base (executable-find "gswin32c.exe"))
   ;; standard Ghostscript   
   "gs")
  "Program to convert PS and PDF files to PNG."
  :type 'file
  :version "28.1")
--8<---------------cut here---------------end--------------->8---

Best, Arash