0

I strugle to give my emacs access to ghostscript (to make doc-view show me pdf previews), and seem lost in a plethora of internet advises about how to install gs. Here is what I have done, and it does not work yet:

  1. I have installed ghostscript at

C:\Program Files (x86)\gs\gs9.09\bin\gswin32.exe

  1. I have set the environmental PATH to

    C:\Program Files (x86)\gs\gs9.09\bin

  2. In my emacs init file I have the following code:

    (add-to-list 'load-path "C:/Program Files (x86)/gs/gs9.09/bin/")

    (add-to-list 'load-path "C:/Program Files (x86)/gs/gs9.09/lib/")

When I give the following shell command from emacs

 M-! gsview32 

"gsview32" is not recognized as an internal or external command, operable program or batch file.

What is lacking in my setup above (and what is not needed)?

3
  • 1
    It probably should be exec-path, not load-path. Also, how exactly did you set environment variables (through Windows dialog, or by calling setenv in Emacs?). What shell are you running in Emacs (is it Cygwin's bash or cmd.exe?). If it is cmd.exe, what happens if you type in shell where gsview32?
    – wvxvw
    Commented May 10, 2016 at 8:58
  • Try this: (setq doc-view-ghostscript-program "/path/to/gs") In my experience, the exec-path is for things like helping Emacs to create the *Completions* buffer -- however, that is unrelated to helping Emacs find an executable to start a process as that relies upon the environmental variable for the $PATH. You can see what your $PATH by typing: M-x eval-expression RET (getenv "PATH") RET
    – lawlist
    Commented May 10, 2016 at 16:13
  • I have tried both exec-path and load-path, but none of them made gsview32 active. my path were C:\Program Files (x86)\emacs\emacs25093\bin C:\Program Files (x86)\gs\gs9.09\bin
    – myotis
    Commented May 10, 2016 at 17:20

1 Answer 1

2

The variable doc-view-ghostscript-program is customizable:

(setq doc-view-ghostscript-program "C:/Program Files (x86)/gs/gs9.09/bin/gswin32.exe")
11
  • Thanks for your suggestion, but gsview is still dead, I get the same error-message as in my original question. Should I try ghostscript that I have in a Cygwin installation instead?
    – myotis
    Commented May 10, 2016 at 17:25
  • My answer will ensure that you can view a pdf file in doc-view-mode IF you have the required dll files needed to view png images on Emacs for Windows. My answer does not attempt to set the $PATH variable in your Windows installation, or within Emacs. If you want to execute shell-commands from within Emacs that are able to locate a particular executable on your hard drive, then you'll need to set the $PATH correctly -- either in Widows system variables or within Emacs. If your ultimate goal is to view pdf files in Emacs in doc-view-mode, then this answer suffices.
    – lawlist
    Commented May 10, 2016 at 17:30
  • yes now it works! :) nice, I can preview both pdf and doc files! Thanks a lot!
    – myotis
    Commented May 10, 2016 at 17:34
  • Pdf files are visible nicely, but not doc or odt files. Is it possible to make them visible too?
    – myotis
    Commented May 10, 2016 at 17:41
  • I'm working on testing my comment on your previous thread about preview, which is to hit the space bar on any file in dired-mode and have a little window pop-up showing a human readable image of a variety of files. I liked the description of the free program seer, but it requires Window Vista or greater. I have been using Windows XP within a virtual container (Parallels) on OSX to build Emacs for Windows and play with it. I'm building a new Emacs master branch this morning, and am installing Windows 7 in a virtual container. But I have work-related stuff to do also today. . . .
    – lawlist
    Commented May 10, 2016 at 18:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.