[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex 59ccf34 35/36: Check the viewer executable exist
From: |
Stefan Monnier |
Subject: |
[elpa] externals/auctex 59ccf34 35/36: Check the viewer executable exists before opening it. |
Date: |
Fri, 28 Nov 2014 17:25:54 +0000 |
branch: externals/auctex
commit 59ccf3416d53064785d3feee8bcbf8074612386a
Author: Mosè Giordano <address@hidden>
Date: Fri Nov 28 15:58:06 2014 +0100
Check the viewer executable exists before opening it.
* tex.el (TeX-view-program-list-builtin): Add the new third
element to each item.
(TeX-view-program-list): Document new third element of items in
doc string. Adapt the type.
(TeX-view-command-raw): Check whether the viewer executable
exists. (Bug#19121)
* doc/auctex.texi (Starting Viewers): Document change to
`TeX-view-program-list'.
* doc/changes.texi: Mention it.
---
ChangeLog | 14 ++++++
doc/auctex.texi | 6 +++
doc/changes.texi | 4 ++
tex.el | 123 ++++++++++++++++++++++++++++++++---------------------
4 files changed, 98 insertions(+), 49 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 95ee0ea..6c0c802 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2014-11-28 Mos� Giordano <address@hidden>
+
+ * tex.el (TeX-view-program-list-builtin): Add the new third
+ element to each item.
+ (TeX-view-program-list): Document new third element of items in
+ doc string. Adapt the type.
+ (TeX-view-command-raw): Check whether the viewer executable
+ exists. (Bug#19121)
+
+ * doc/auctex.texi (Starting Viewers): Document change to
+ `TeX-view-program-list'.
+
+ * doc/changes.texi: Mention it.
+
2014-11-28 Stefan Monnier <address@hidden>
* style/siunitx.el (tex): Require tex because its indispensable
diff --git a/doc/auctex.texi b/doc/auctex.texi
index ea22c71..8fb997c 100644
--- a/doc/auctex.texi
+++ b/doc/auctex.texi
@@ -3045,6 +3045,12 @@ exact format to use.) The command line can also contain
placeholders as
defined in @code{TeX-expand-list} which are expanded before the viewer
is called.
+The third element of each item is a string, or a list of strings, with
+the name of the executable, or executables, needed to open the output
+file in the viewer. Placeholders defined in @code{TeX-expand-list} can
+be used here. This element is optional and is used to check whether the
+viewer is actually available on the system.
+
A built-in viewer spec from @code{TeX-view-program-list-builtin} can be
overwritten by defining a new viewer spec with the same name.
@end defopt
diff --git a/doc/changes.texi b/doc/changes.texi
index 0dd30bd..a4b2e76 100644
--- a/doc/changes.texi
+++ b/doc/changes.texi
@@ -14,6 +14,10 @@
@item
New option @code{TeX-file-line-error} allows to select file:line:error
style for error messages.
+
address@hidden
address@hidden can contain, as third optional element of
+each item, the name of the executable(s) needed to open the viewer.
@end itemize
@heading News in 11.88
diff --git a/tex.el b/tex.el
index 3b530cb..b422ed1 100644
--- a/tex.el
+++ b/tex.el
@@ -1128,14 +1128,14 @@ the requirements are met."
(defvar TeX-view-program-list-builtin
(cond
((eq system-type 'windows-nt)
- '(("Yap" ("yap -1" (mode-io-correlate " -s %n%b") " %o"))
- ("dvips and start" "dvips %d -o && start \"\" %f")
- ("start" "start \"\" %o")))
+ '(("Yap" ("yap -1" (mode-io-correlate " -s %n%b") " %o") "yap")
+ ("dvips and start" "dvips %d -o && start \"\" %f" ,(list "dvips"
"start"))
+ ("start" "start \"\" %o" "start")))
((eq system-type 'darwin)
- '(("Preview.app" "open -a Preview.app %o")
- ("Skim" "open -a Skim.app %o")
- ("displayline" "displayline %n %o %b")
- ("open" "open %o")))
+ '(("Preview.app" "open -a Preview.app %o" "open")
+ ("Skim" "open -a Skim.app %o" "open")
+ ("displayline" "displayline %n %o %b" "displayline")
+ ("open" "open %o" "open")))
(t
`(("xdvi" ("%(o?)xdvi"
(mode-io-correlate " -sourceposition \"%n %b\" -editor \"%cS\"")
@@ -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
@@ -1169,7 +1169,7 @@ definition of built-in ones. The latter variable also
contains a
description of the data format.")
(defcustom TeX-view-program-list nil
- "Alist of viewer specifications.
+ "List of viewer specifications.
This variable can be used to specify how a viewer is to be
invoked and thereby add new viewers on top of the built-in list
of viewers defined in `TeX-view-program-list-builtin' or override
@@ -1188,6 +1188,12 @@ the command line parts. Parts with a predicate are only
considered if the predicate was evaluated with a positive result.
Note that the command line can contain placeholders as defined in
`TeX-expand-list' which are expanded before the viewer is called.
+The third element of the item is optional and is a string, or a
+list of strings, with the name of the executable, or executables,
+needed to open the output file in the viewer. Placeholders
+defined in `TeX-expand-list' can be used here. This element is
+used to check whether the viewer is actually available on the
+system.
The use of a function as the second element only works if the
View command in `TeX-command-list' makes use of the hook
@@ -1198,35 +1204,39 @@ show up in the customization interface for this
variable after
restarting Emacs."
:group 'TeX-view
:type
- `(alist
- :key-type (string :tag "Name")
- :value-type
- (choice
- (group :tag "Command" (string :tag "Command"))
- (group :tag "Command parts"
- (repeat
- :tag "Command parts"
- (choice
- (string :tag "Command part")
- (list :tag "Predicate and command part"
- ,(let (list)
- ;; Build the list of available predicates.
- (mapc (lambda (spec)
- (add-to-list 'list `(const ,(car spec))))
- (append TeX-view-predicate-list
- TeX-view-predicate-list-builtin))
- ;; Sort the list alphabetically.
- (setq list (sort list
- (lambda (a b)
- (string<
- (downcase (symbol-name (cadr a)))
- (downcase (symbol-name (cadr b)))))))
- `(choice
- (choice :tag "Predicate" ,@list)
- (repeat :tag "List of predicates"
- (choice :tag "Predicate" ,@list))))
- (string :tag "Command part")))))
- (group :tag "Function" function))))
+ `(repeat
+ (list
+ (string :tag "Name")
+ (choice
+ (group :tag "Command" (string :tag "Command"))
+ (group :tag "Command parts"
+ (repeat
+ :tag "Command parts"
+ (choice
+ (string :tag "Command part")
+ (list :tag "Predicate and command part"
+ ,(let (list)
+ ;; Build the list of available predicates.
+ (mapc (lambda (spec)
+ (add-to-list 'list `(const ,(car spec))))
+ (append TeX-view-predicate-list
+ TeX-view-predicate-list-builtin))
+ ;; Sort the list alphabetically.
+ (setq list (sort list
+ (lambda (a b)
+ (string<
+ (downcase (symbol-name (cadr a)))
+ (downcase (symbol-name (cadr
b)))))))
+ `(choice
+ (choice :tag "Predicate" ,@list)
+ (repeat :tag "List of predicates"
+ (choice :tag "Predicate" ,@list))))
+ (string :tag "Command part")))))
+ (group :tag "Function" function))
+ (choice :tag "Viewer executable(s)"
+ (string :tag "One executable")
+ (repeat :tag "List of executables" (string :tag "Name"))
+ (const :tag "No executable" nil)))))
;; XXX: Regarding a possibility to (manually) run an update command,
;; one could support this through `TeX-view' by letting it temporarily
@@ -1319,16 +1329,31 @@ 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)
+ (catch 'notfound
+ (dolist (exec executable t)
+ (unless (executable-find (TeX-command-expand exec nil))
+ (throw 'notfound 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.
@@ -1338,7 +1363,7 @@ predicates are true, nil otherwise."
((null spec)
(error
(format "Unknown %S viewer. \
-Check the `TeX-view-program-selection' variable." 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.
- [elpa] externals/auctex 3909e4c 06/36: Several changes suggested by byte-compiler warnings., (continued)
- [elpa] externals/auctex 3909e4c 06/36: Several changes suggested by byte-compiler warnings., Stefan Monnier, 2014/11/28
- [elpa] externals/auctex a3f4cac 29/36: Implement forward-search for View command on TeX-region., Stefan Monnier, 2014/11/28
- [elpa] externals/auctex 0c2cfc8 09/36: Replace `read-string' with `TeX-read-string', Stefan Monnier, 2014/11/28
- [elpa] externals/auctex acf1c76 31/36: Document LaTeX-command-section., Stefan Monnier, 2014/11/28
- [elpa] externals/auctex 15edd9b 23/36: Omit f-f hooks and more with TeX-region-create, Stefan Monnier, 2014/11/28
- [elpa] externals/auctex 8f7c399 30/36: Implement LaTeX-command-section., Stefan Monnier, 2014/11/28
- [elpa] externals/auctex e4101ed 25/36: Adapt bug intro text for debbugs., Stefan Monnier, 2014/11/28
- [elpa] externals/auctex 7b427a7 34/36: Merge ELPA changes fixing some byte-compile warnings., Stefan Monnier, 2014/11/28
- [elpa] externals/auctex 58bd866 28/36: Fix indentation in LaTeX-env-figure in a corner case., Stefan Monnier, 2014/11/28
- [elpa] externals/auctex e1ec6a0 33/36: Make second argument of LaTeX-label optional., Stefan Monnier, 2014/11/28
- [elpa] externals/auctex 59ccf34 35/36: Check the viewer executable exists before opening it.,
Stefan Monnier <=
- [elpa] externals/auctex e739b85 32/36: Move preview/ to top-level., Stefan Monnier, 2014/11/28
- [elpa] externals/auctex c390682 36/36: Merge from upstream., Stefan Monnier, 2014/11/28