auctex-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[AUCTeX-diffs] GNU AUCTeX branch, master, updated. 40963e5f00d689045f3c7


From: Mosè Giordano
Subject: [AUCTeX-diffs] GNU AUCTeX branch, master, updated. 40963e5f00d689045f3c707d1f293b929547ced2
Date: Fri, 21 Aug 2015 13:24:36 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU AUCTeX".

The branch, master has been updated
       via  40963e5f00d689045f3c707d1f293b929547ced2 (commit)
      from  a4d23f65e86c5f18a0722d9f037daa61b54beb91 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 40963e5f00d689045f3c707d1f293b929547ced2
Author: Mosè Giordano <address@hidden>
Date:   Fri Aug 21 15:23:24 2015 +0200

    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'.

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)

-----------------------------------------------------------------------

Summary of changes:
 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(-)


hooks/post-receive
-- 
GNU AUCTeX



reply via email to

[Prev in Thread] Current Thread [Next in Thread]