diff --git a/tex.el b/tex.el index 3b530cb..505ce5c 100644 --- a/tex.el +++ b/tex.el @@ -1147,10 +1147,10 @@ the requirements are met." (paper-letter " -paper us") (paper-legal " -paper legal") (paper-executive " -paper 7.25x10.5in") - " %d")) - ("dvips and gv" "%(o?)dvips %d -o && gv %f") - ("gv" "gv %o") - ("xpdf" ("xpdf -remote %s -raise %o" (mode-io-correlate " %(outpage)"))) + " %d") "%(o?)xdvi") + ("dvips and gv" "%(o?)dvips %d -o && gv %f" ,(list "%(o?)dvips" "gv")) + ("gv" "gv %o" "gv") + ("xpdf" ("xpdf -remote %s -raise %o" (mode-io-correlate " %(outpage)")) "xpdf") ("Evince" ,(if (TeX-evince-dbus-p :forward) 'TeX-evince-sync-view `("evince" (mode-io-correlate @@ -1159,9 +1159,9 @@ the requirements are met." ,(if (string-match "--page-index" (shell-command-to-string "evince --help")) " -i %(outpage)" - " -p %(outpage)")) " %o"))) - ("Okular" ("okular --unique %o" (mode-io-correlate "#src:%n%a"))) - ("xdg-open" "xdg-open %o")))) + " -p %(outpage)")) " %o")) "evince") + ("Okular" ("okular --unique %o" (mode-io-correlate "#src:%n%a")) "okular") + ("xdg-open" "xdg-open %o"))) "xdg-open") "Alist of built-in viewer specifications. This variable should not be changed by the user who can use `TeX-view-program-list' to add new viewers or overwrite the @@ -1319,16 +1319,28 @@ predicates are true, nil otherwise." (defun TeX-view-command-raw () "Choose a viewer and return its unexpanded command string." (let ((selection TeX-view-program-selection) - entry viewer spec command) + entry viewer item executable spec command) ;; Find the appropriate viewer. (while (and (setq entry (pop selection)) (not viewer)) (when (TeX-view-match-predicate (car entry)) (setq viewer (cadr entry)))) (unless viewer (error "No matching viewer found")) - ;; Get the command line or function spec. - (setq spec (cadr (assoc viewer (append TeX-view-program-list - TeX-view-program-list-builtin)))) + (setq item (assoc viewer (append TeX-view-program-list + TeX-view-program-list-builtin)) + ;; Get the command line or function spec. + spec (cadr item) + ;; Get the name of the executable(s) associated to the viewer. + executable (nth 2 item)) + ;; Check the executable exists. + (unless (or (null executable) + (cond ((stringp executable) + (executable-find (TeX-command-expand executable nil))) + ((listp executable) + (dolist (exec executable) + (executable-find (TeX-command-expand exec nil)))))) + (error (format "Cannot find %S viewer. \ +Select another one in `TeX-view-program-selection'" viewer))) (cond ((functionp spec) ;; Converting the function call to a string is ugly, but ;; the backend currently only supports strings. @@ -1337,8 +1349,8 @@ predicates are true, nil otherwise." spec) ((null spec) (error - (format "Unknown %S viewer. \ -Check the `TeX-view-program-selection' variable." viewer))) + (format "Unknown %S viewer. \ +Check the `TeX-view-program-selection' variable" viewer))) (t ;; Build the unexpanded command line. Pieces with predicates are ;; only added if the predicate is evaluated positively.