Hi Davide, 2014-11-20 16:07 GMT+01:00 Davide G. M. Salvetti <sa...@debian.org>: > Package: auctex > Version: 11.83 > Severity: normal > Usertags: bugs.debian.org/409795 > > Neither `C-c C-c', nor `C-c C-v', nor `tool-bar view' appear to report > any error if the viewer selected by `TeX-view-program-selection' isn't > installed. > > It would be useful if AUCTeX would check if the selected viewer is > installed on the system, falling back to some other viewer if available; > at a minimum, however, AUCTeX should give some clue to the user about > the failure to start a viewer. > > This bug has been originally reported by a Debian user: see > <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=409795>, in > particular items marked `0' and `2' by the original submitter.
The attached patch addresses this problem: it adds a third, optional, element to `TeX-view-program-list' and `TeX-view-program-list-builtin', with the name of the executable associated to that viewer and checks inside `TeX-view-command-raw' if that executable exists. I'm not very fond of this solution because it needs to add another element to a widely customized variable (although the element is optional, so it won't break backward compatibility), but I have no other idea to fix it. Does someone have other suggestions? Bye, Mosè
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.
_______________________________________________ bug-auctex mailing list bug-auctex@gnu.org https://lists.gnu.org/mailman/listinfo/bug-auctex