[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex 40963e5 08/78: Check engine before running LaTeX
From: |
Tassilo Horn |
Subject: |
[elpa] externals/auctex 40963e5 08/78: Check engine before running LaTeX command. |
Date: |
Mon, 19 Oct 2015 09:10:39 +0000 |
branch: externals/auctex
commit 40963e5f00d689045f3c707d1f293b929547ced2
Author: Mosè Giordano <address@hidden>
Commit: Mosè Giordano <address@hidden>
Check engine before running LaTeX command.
* tex-buf.el (TeX-check-engine): New customizable variable.
(TeX-check-engine-list): New variable.
(TeX-check-engine-add-engines): New function.
(TeX-check-engine): New function.
(TeX-command): Use `TeX-check-engine' and update docstring
accordingly.
* style/fontspec.el ("fontspec"): Add engine restrictions.
* doc/auctex.texi (Processor Options): Document
`TeX-check-engine'.
* doc/changes.texi: Mention `TeX-check-engine'.
---
ChangeLog | 16 +++++++++
doc/auctex.texi | 14 ++++++++
doc/changes.texi | 5 +++
style/fontspec.el | 1 +
tex-buf.el | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
5 files changed, 132 insertions(+), 1 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e2c8ac8..7201d85 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2015-08-21 Mos� Giordano <address@hidden>
+
+ * tex-buf.el (TeX-check-engine): New customizable variable.
+ (TeX-check-engine-list): New variable.
+ (TeX-check-engine-add-engines): New function.
+ (TeX-check-engine): New function.
+ (TeX-command): Use `TeX-check-engine' and update docstring
+ accordingly.
+
+ * style/fontspec.el ("fontspec"): Add engine restrictions.
+
+ * doc/auctex.texi (Processor Options): Document
+ `TeX-check-engine'.
+
+ * doc/changes.texi: Mention `TeX-check-engine'.
+
2015-08-20 Mos� Giordano <address@hidden>
* tex-buf.el (TeX-error-overview-jump-to-source)
diff --git a/doc/auctex.texi b/doc/auctex.texi
index 09935c9..141afff 100644
--- a/doc/auctex.texi
+++ b/doc/auctex.texi
@@ -2950,6 +2950,20 @@ command can either be a variable or a string. An empty
string or nil
means there is no command available.
@end defopt
+Some @LaTeX{} packages requires the document to be compiled with a
+specific engine. Notably examples are fontspec and polyglossia
+packages, which require address@hidden and address@hidden engines. If you try
to
+compile a document which loads one of such packages and the set engine
+is not one of those allowed you will be asked to select a different
+engine before running the @LaTeX{} command. If you do not want to be
+warned by @AUCTeX{} in these cases, customize the option
address@hidden
+
address@hidden TeX-check-engine
+This boolean option controls whether @AUCTeX{} should check the correct
+engine has been set before running @LaTeX{} commands.
address@hidden defopt
+
As shown above, @AUCTeX{} handles in a special way most of the main
options that can be given to the @TeX{} processors. When you need to
pass to the @TeX{} processor arbitrary options not handled by @AUCTeX{},
diff --git a/doc/changes.texi b/doc/changes.texi
index 1dd552d..2178387 100644
--- a/doc/changes.texi
+++ b/doc/changes.texi
@@ -34,6 +34,11 @@ Indent @samp{\[...\]} math mode as a regular environment by
default.
@item
@code{TeX-view-program-list} can contain, as third optional element of
each item, the name of the executable(s) needed to open the viewer.
+
address@hidden
+When new option @code{TeX-check-engine} is non-nil, before running
address@hidden commands @AUCTeX{} will check whether the correct engine has
+been set, based upon known restrictions posed by @LaTeX{} packages.
@end itemize
@heading News in 11.88
diff --git a/style/fontspec.el b/style/fontspec.el
index 144b976..5ec7bb4 100644
--- a/style/fontspec.el
+++ b/style/fontspec.el
@@ -166,6 +166,7 @@ to retrieve the list of fonts."
(TeX-add-style-hook
"fontspec"
(lambda ()
+ (TeX-check-engine-add-engines 'luatex 'xetex)
(TeX-run-style-hooks "expl3" "xparse")
(TeX-add-symbols
;; Font selection
diff --git a/tex-buf.el b/tex-buf.el
index cdd5fe2..3be47d7 100644
--- a/tex-buf.el
+++ b/tex-buf.el
@@ -332,6 +332,96 @@ This works only with TeX commands and if the
(defconst TeX-error-overview-buffer-name "*TeX errors*"
"Name of the buffer in which to show error list.")
+(defcustom TeX-check-engine t
+ "Whether AUCTeX should check the correct engine has been set before running
LaTeX commands."
+ :group 'TeX-command
+ :type 'boolean)
+
+(defvar TeX-check-engine-list '(default luatex omega xetex)
+ "List of engines required by the loaded TeX packages.
+
+Do not set this variable directly, use
+`TeX-check-engine-add-engines' to specify required engines.")
+(make-variable-buffer-local 'TeX-check-engine-list)
+
+(defun TeX-check-engine-add-engines (&rest engines)
+ "Add ENGINES to list of required engines.
+
+Set `TeX-check-engine-list' to the intersection between the list
+itself and the list of provided engines.
+
+See for example style/fontspec.el"
+ (let ((list TeX-check-engine-list)
+ (res nil))
+ (setq TeX-check-engine-list
+ ;; The following is based on the definition of `cl-intersection' of
+ ;; GNU Emacs.
+ (and list engines
+ (if (equal list engines) list
+ (or (>= (length list) (length engines))
+ (setq list (prog1 engines (setq engines list))))
+ (while engines
+ (if (memq (car engines) list)
+ (push (car engines) res))
+ (pop engines))
+ res)))))
+
+(defun TeX-check-engine (name)
+ "Check the correct engine has been set.
+
+Look into `TeX-check-engine-list' for the required engines.
+
+NAME is the command to be run. Actually do the check only if the
+variable `TeX-check-engine' is non-nil and LaTeX is the command
+to be run."
+ (and
+ (string= name "LaTeX")
+ TeX-check-engine
+ TeX-check-engine-list
+ (null (memq TeX-engine TeX-check-engine-list))
+ (memq TeX-engine '(default luatex omega xetex))
+ ;; The set engine is not listed in `TeX-check-engine-list'. We check only
+ ;; builtin engines because we can't take care of custom ones. Do nothing if
+ ;; there is no allowed engine, we don't know what to do in that case.
+ (let ((length (length TeX-check-engine-list))
+ (name-alist '((default . "TeX")
+ (luatex . "LuaTeX")
+ (omega . "Omega")
+ (xetex . "XeTeX")))
+ (completion-ignore-case t)
+ (engine nil))
+ (when
+ (cond
+ ;; There is exactly one allowed engine.
+ ((= length 1)
+ (setq engine (car TeX-check-engine-list))
+ (y-or-n-p (format "%s is required to build this document.
+Do you want to use this engine?" (cdr (assoc engine name-alist)))))
+ ;; More than one engine is allowed.
+ ((> length 1)
+ (if (y-or-n-p (format "%s are required to build this document.
+Do you want to select one of these engines?"
+ (mapconcat
+ (lambda (elt) (cdr (assoc elt name-alist)))
+ TeX-check-engine-list ", ")))
+ (setq engine
+ (car (rassoc
+ (completing-read
+ (format
+ "Choose between %s: "
+ (mapconcat
+ (lambda (elt) (cdr (assoc elt name-alist)))
+ TeX-check-engine-list ", "))
+ (mapcar
+ (lambda (elt) (cdr (assoc elt name-alist)))
+ TeX-check-engine-list))
+ name-alist))))))
+ (TeX-engine-set engine)
+ (when (and (fboundp 'add-file-local-variable)
+ (y-or-n-p "Do you want to remember the choice?"))
+ (add-file-local-variable 'TeX-engine engine)
+ (save-buffer))))))
+
(defun TeX-command (name file &optional override-confirm)
"Run command NAME on the file returned by calling FILE.
@@ -343,7 +433,12 @@ Use the information in `TeX-command-list' to determine how
to run
the command.
If OVERRIDE-CONFIRM is a prefix argument, confirmation will be
-asked if it is positive, and suppressed if it is not."
+asked if it is positive, and suppressed if it is not.
+
+Run function `TeX-check-engine' to check the correct engine has
+been set."
+ (TeX-check-engine name)
+
(cond ((eq file 'TeX-region-file)
(setq TeX-current-process-region-p t))
((eq file 'TeX-master-file)
- [elpa] externals/auctex 30be9cc 09/78: Add support for prettify-symbols-mode, (continued)
- [elpa] externals/auctex 30be9cc 09/78: Add support for prettify-symbols-mode, Tassilo Horn, 2015/10/19
- [elpa] externals/auctex eff71a7 10/78: Change | syntax to punctuation; fixes bug#21366, Tassilo Horn, 2015/10/19
- [elpa] externals/auctex a4d23f6 07/78: Add menu and new functions for error overview., Tassilo Horn, 2015/10/19
- [elpa] externals/auctex a85d7c6 15/78: Add support for undocumented macros `\captionbox[*]'., Tassilo Horn, 2015/10/19
- [elpa] externals/auctex a3e3ab8 14/78: Add new style transparent.el., Tassilo Horn, 2015/10/19
- [elpa] externals/auctex 8d5acb0 13/78: Do not indent the content of `filecontents[*]' env., Tassilo Horn, 2015/10/19
- [elpa] externals/auctex 57338ec 24/78: Improve my last commit, Tassilo Horn, 2015/10/19
- [elpa] externals/auctex 400609e 18/78: New TeX--if-macro-fboundp compatibility macro, Tassilo Horn, 2015/10/19
- [elpa] externals/auctex 08ab3c1 23/78: Allow hiding ^ and _ script signs, Tassilo Horn, 2015/10/19
- [elpa] externals/auctex 0b3a6e8 12/78: Do not indent the content of `Form' environment., Tassilo Horn, 2015/10/19
- [elpa] externals/auctex 40963e5 08/78: Check engine before running LaTeX command.,
Tassilo Horn <=
- [elpa] externals/auctex 33cee84 19/78: Allow TeX-command-sequence to process the region, Tassilo Horn, 2015/10/19
- [elpa] externals/auctex 513490f 22/78: Implement multi-level script fontification, Tassilo Horn, 2015/10/19
- [elpa] externals/auctex 76eb240 25/78: Docfix, Tassilo Horn, 2015/10/19
- [elpa] externals/auctex a07f436 16/78: Implement TeX-update., Tassilo Horn, 2015/10/19
- [elpa] externals/auctex dbc87df 17/78: Generate PDF via dvips+ps2pdf., Tassilo Horn, 2015/10/19
- [elpa] externals/auctex dd9adef 21/78: Case-sensitive mode detection + AMS-TeX fixes, Tassilo Horn, 2015/10/19
- [elpa] externals/auctex da7419f 42/78: Add new style AlegreyaSans.el., Tassilo Horn, 2015/10/19
- [elpa] externals/auctex 9cfd5d8 47/78: Improve LaTeX-find-matching-end, Tassilo Horn, 2015/10/19
- [elpa] externals/auctex 647a8fc 29/78: Fixes for "run-all" on current section, Tassilo Horn, 2015/10/19
- [elpa] externals/auctex 5ed22c0 45/78: FiX TeX error parsing., Tassilo Horn, 2015/10/19