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. 667f4e9351702ea1bd54c


From: Ikumi Keita
Subject: [AUCTeX-diffs] GNU AUCTeX branch, master, updated. 667f4e9351702ea1bd54c127bafa2dbf368b1401
Date: Mon, 26 Nov 2018 01:44:15 -0500 (EST)

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  667f4e9351702ea1bd54c127bafa2dbf368b1401 (commit)
       via  d2b054747a3a2e8244d89101dfaaa1110607fe2c (commit)
      from  a20430d63b94c80bb4f7e05736cd2241425d469b (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 667f4e9351702ea1bd54c127bafa2dbf368b1401
Author: Ikumi Keita <address@hidden>
Date:   Thu Nov 15 00:26:36 2018 +0900

    Defer running style hook until options are given actually
    
    * latex.el (LaTeX-arg-usepackage-read-packages-with-options): Don't
    run the style hooks before reading package options, just load the
    style files for completion of package options.
    (LaTeX-arg-usepackage): Run style hooks actually after the package
    options are given.
    (TeX-arg-document): Don't run the style hooks before reading class
    options, just load the style file for completion of class options.
    The style hooks are run afterward by `TeX-update-style' anyway.
    ; Mark unused argument with underscore.
    * style/exam.el ("exam"): Prepare `LaTeX-exam-class-options' to have
    its full values outside the style hook along with the above idea.
    * style/mathtools.el ("mathtools"):
    * style/empheq.el ("empheq"):
    * style/graphics.el ("graphics"): Set `LaTeX-*****-package-options'
    outside the style hook along with the above idea.

diff --git a/latex.el b/latex.el
index 55945c0..a7be8de 100644
--- a/latex.el
+++ b/latex.el
@@ -2234,7 +2234,7 @@ May be reset with `\\[universal-argument] 
\\[TeX-normal-mode]'.")
 
 To insert a hook here, you must insert it in the appropiate style file.")
 
-(defun TeX-arg-document (optional &optional _ignore)
+(defun TeX-arg-document (_optional &optional _ignore)
   "Insert arguments to documentclass.
 OPTIONAL and IGNORE are ignored."
   (let* ((TeX-file-extensions '("cls"))
@@ -2255,7 +2255,7 @@ OPTIONAL and IGNORE are ignored."
                 LaTeX-global-class-files nil nil nil nil LaTeX-default-style))
     ;; Clean up hook before use.
     (setq TeX-after-document-hook nil)
-    (TeX-run-style-hooks style)
+    (TeX-load-style style)
     (setq var (intern (format "LaTeX-%s-class-options" style)))
     (setq defopt (if (stringp LaTeX-default-options)
                     LaTeX-default-options
@@ -2318,7 +2318,7 @@ of the options, nil otherwise."
                    "Packages: " TeX-global-input-files))
     ;; Clean up hook before use in `LaTeX-arg-usepackage-insert'.
     (setq LaTeX-after-usepackage-hook nil)
-    (mapc 'TeX-run-style-hooks packages)
+    (mapc #'TeX-load-style packages)
     ;; Prompt for options only if at least one package has been supplied, 
return
     ;; nil otherwise.
     (when packages
@@ -2361,7 +2361,8 @@ OPTIONAL is ignored."
   (let* ((packages-options (LaTeX-arg-usepackage-read-packages-with-options))
         (packages (car packages-options))
         (options (cdr packages-options)))
-    (LaTeX-arg-usepackage-insert packages options)))
+    (LaTeX-arg-usepackage-insert packages options)
+    (apply #'TeX-run-style-hooks packages)))
 
 (defun LaTeX-insert-usepackages ()
   "Prompt for the insertion of usepackage macros until empty
diff --git a/style/empheq.el b/style/empheq.el
index b0231e8..5680132 100644
--- a/style/empheq.el
+++ b/style/empheq.el
@@ -1,6 +1,6 @@
 ;;; empheq.el --- AUCTeX style for `empheq.sty' (v2.14)
 
-;; Copyright (C) 2016, 2017 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
 
 ;; Author: Arash Esbati <address@hidden>
 ;; Maintainer: address@hidden
@@ -98,6 +98,11 @@
 (defvar LaTeX-empheq-package-options
   '("overload" "overload2" "ntheorem" "newmultline" "oldmultline")
   "Package options for the empheq package.")
+(TeX-load-style "mathtools")
+;; Add elements from `LaTeX-mathtools-package-options' only once
+;; and not every time the style hook runs
+(dolist (elt LaTeX-mathtools-package-options)
+  (add-to-list 'LaTeX-empheq-package-options elt))
 
 ;; Setup for \Declare(Left|Right)Delimiter:
 
@@ -269,11 +274,6 @@ number of ampersands if possible."
    ;; Load amsmath.el and mathtools.el
    (TeX-run-style-hooks "amsmath" "mathtools")
 
-   ;; Add elements from `LaTeX-mathtools-package-options' only once
-   ;; and not every time the style hook runs
-   (dolist (elt LaTeX-mathtools-package-options)
-     (add-to-list 'LaTeX-empheq-package-options elt))
-
    ;; Local version of key-val options
    (setq LaTeX-empheq-key-val-options-local
         (copy-alist LaTeX-empheq-key-val-options))
diff --git a/style/exam.el b/style/exam.el
index b761128..20e66f9 100644
--- a/style/exam.el
+++ b/style/exam.el
@@ -36,6 +36,11 @@
   '("answers" "noanswers" "cancelspace" "nocancelspace" "addpoints")
   "Class options for the exam class.")
 
+(TeX-load-style "article")
+;; Add options from `LaTeX-article-class-options' only once:
+(dolist (opt LaTeX-article-class-options)
+  (add-to-list 'LaTeX-exam-class-options opt))
+
 (defun LaTeX-exam-insert-item ()
   "Insert a new item in an environment from exam class.
 Item inserted depends on the environment."
@@ -63,9 +68,6 @@ Arguments NAME and TYPE are the same as for the function
  "exam"
  (lambda ()
    (TeX-run-style-hooks "article")
-   ;; Add options from `LaTeX-article-class-options' only once:
-   (dolist (opt LaTeX-article-class-options)
-     (add-to-list 'LaTeX-exam-class-options opt))
    ;; Make our label prefix available ...
    (let ((envs '("questions")))
      (dolist (env envs)
diff --git a/style/graphics.el b/style/graphics.el
index a48e612..b74cd4d 100644
--- a/style/graphics.el
+++ b/style/graphics.el
@@ -2,11 +2,16 @@
 
 ;;; Code:
 
+;; Load "graphicx" explicitly to access `LaTeX-graphicx-package-options'
+;; before running style hook "graphics".  This is necessary to have
+;; support for completion of package options of "usepackage".
+(TeX-load-style "graphicx")
+(defvar LaTeX-graphics-package-options LaTeX-graphicx-package-options)
+
 (TeX-add-style-hook "graphics"
  (function
   (lambda ()
-    (TeX-run-style-hooks "graphicx")
-    (setq LaTeX-graphics-package-options LaTeX-graphicx-package-options)))
+    (TeX-run-style-hooks "graphicx")))
  LaTeX-dialect)
 
 ;;; graphics.el ends here.
diff --git a/style/mathtools.el b/style/mathtools.el
index f36a13d..cfac6ce 100644
--- a/style/mathtools.el
+++ b/style/mathtools.el
@@ -1,6 +1,6 @@
 ;;; mathtools.el --- Style hook for the LaTeX package `mathtools'.
 
-;; Copyright (C) 2011-2012, 2014, 2016 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2012, 2014, 2016, 2018 Free Software Foundation, Inc.
 
 ;; Author: Mads Jensen <address@hidden>
 ;; Created: 2011-02-13
@@ -47,6 +47,9 @@
     ;; via nonrobust package option)
     "nonrobust")
   "Package options for the mathtools package.")
+(TeX-load-style "amsmath")
+(dolist (elt LaTeX-amsmath-package-options)
+  (add-to-list 'LaTeX-mathtools-package-options elt))
 
 (defvar LaTeX-mathtools-key-val-options
   '(("showonlyrefs")
@@ -240,9 +243,6 @@ Put line break macro on the last line.  Next, insert an 
ampersand."
    ;; mathtools requires amsmath, as some bugs in amsmath are fixed
    (TeX-run-style-hooks "amsmath")
 
-   (dolist (elt LaTeX-amsmath-package-options)
-     (add-to-list 'LaTeX-mathtools-package-options elt))
-
    (LaTeX-add-environments
     ;; 3.4.1 Matrices
     '("matrix*"  [ "Vertical alignment (l, r or c (default))" ])

commit d2b054747a3a2e8244d89101dfaaa1110607fe2c
Author: Ikumi Keita <address@hidden>
Date:   Sat Nov 17 21:30:11 2018 +0900

    Fix not to run wrong style hooks
    
    * tex.el (TeX-style-hook-dialect-weight-alist): Add entry for
    pseudo-dialect `:classopt'.
    (TeX-style-hook-dialect): Add description for `:classopt' in doc
    string.
    * latex.el (LaTeX-common-initialization): Assign style hooks for
    class options into pseudo-dialect `:classopt'.
    Don't set `TeX-PDF-from-DVI' in XeLaTeX document.
    ; Use `LaTeX-dialect' instead of constant symbol `:latex'.
    (TeX-latex-mode): Run style hooks for class options in
    `TeX-update-style-hook', without altering `TeX-active-list'.
    * style/geometry.el ("geometry"):
    * style/graphicx.el ("graphicx"): Don't set `TeX-PDF-from-DVI' in
    XeLaTeX document.
    * style/hyperref.el ("hyperref"): Set `TeX-PDF-from-DVI' to "Dvipdfmx"
    when package option "dvipdfmx" is given for non-XeLaTeX document.
    * tests/latex/latex-test.el (LaTeX-style-hook-with-class-option):
    Refine tests.
    * doc/auctex.texi (Simple Style): Add descriptions for available
    dialects including `:classopt'.

diff --git a/doc/auctex.texi b/doc/auctex.texi
index 6fd65a8..96161b5 100644
--- a/doc/auctex.texi
+++ b/doc/auctex.texi
@@ -4991,11 +4991,18 @@ A symbol indicating a singleton containing one basic 
@TeX{} dialect,
 this symbol shall be selected among:
 @table @code
 @item :latex
-For all files in @LaTeX{} mode, or any mode derived thereof
+For all files in @LaTeX{} mode, or any mode derived thereof.
 @item :bibtex
-For all files in address@hidden mode, or any mode derived thereof
+For all files in address@hidden mode, or any mode derived thereof.
 @item :texinfo
 For all files in @acronym{Texinfo} mode.
address@hidden :plain-tex
+For all files in address@hidden mode, or any mode derived thereof.
address@hidden :context
+For all files in @ConTeXt{} mode.
address@hidden :classopt
+For class options of @LaTeX{} document.  This is provided as
+pseudo-dialect for style hooks associated with class options.
 @end table
 @item
 A logical expression like:
diff --git a/latex.el b/latex.el
index 9cb97de..55945c0 100644
--- a/latex.el
+++ b/latex.el
@@ -5934,12 +5934,17 @@ of `LaTeX-mode-hook'."
            (lambda ()
              (if (local-variable-p 'LaTeX-biblatex-use-Biber (current-buffer))
                  (setq LaTeX-using-Biber LaTeX-biblatex-use-Biber))) nil t)
+
+  ;; Run style hooks associated with class options.
   (add-hook 'TeX-update-style-hook
            (lambda ()
-             ;; Run style hooks associated with class options.
-             (apply #'TeX-run-style-hooks
-                    (apply #'append
-                           (mapcar #'cdr LaTeX-provided-class-options))))
+             (let ((TeX-style-hook-dialect :classopt)
+                   ;; Don't record class option names in
+                   ;; `TeX-active-styles'.
+                   (TeX-active-styles nil))
+               (apply #'TeX-run-style-hooks
+                      (apply #'append
+                             (mapcar #'cdr LaTeX-provided-class-options)))))
            nil t)
   (TeX-run-mode-hooks 'text-mode-hook 'TeX-mode-hook 'LaTeX-mode-hook)
   (when (fboundp 'LaTeX-preview-setup)
@@ -6059,7 +6064,7 @@ function would return non-nil and `(match-string 1)' 
would return
 
   (setq TeX-header-end LaTeX-header-end
        TeX-trailer-start LaTeX-trailer-start)
-  (set (make-local-variable 'TeX-style-hook-dialect) :latex)
+  (set (make-local-variable 'TeX-style-hook-dialect) LaTeX-dialect)
 
   (require 'outline)
   (set (make-local-variable 'outline-level) 'LaTeX-outline-level)
@@ -6458,30 +6463,36 @@ function would return non-nil and `(match-string 1)' 
would return
 
   ;; There must be something better-suited, but I don't understand the
   ;; parsing properly.  -- dak
-  (TeX-add-style-hook "pdftex" 'TeX-PDF-mode-on LaTeX-dialect)
-  (TeX-add-style-hook "pdftricks" 'TeX-PDF-mode-on LaTeX-dialect)
-  (TeX-add-style-hook "pst-pdf" 'TeX-PDF-mode-on LaTeX-dialect)
+  (TeX-add-style-hook "pdftex" #'TeX-PDF-mode-on :classopt)
+  (TeX-add-style-hook "pdftricks" #'TeX-PDF-mode-on :classopt)
+  (TeX-add-style-hook "pst-pdf" #'TeX-PDF-mode-on :classopt)
   (TeX-add-style-hook "dvips"
                      (lambda ()
+                       ;; Leave at user's choice whether to disable
+                       ;; `TeX-PDF-mode' or not.
                        (setq TeX-PDF-from-DVI "Dvips"))
-                     LaTeX-dialect)
+                     :classopt)
   ;; This is now done in style/pstricks.el because it prevents other
   ;; pstricks style files from being loaded.
   ;;   (TeX-add-style-hook "pstricks" 'TeX-PDF-mode-off)
-  (TeX-add-style-hook "psfrag" 'TeX-PDF-mode-off LaTeX-dialect)
-  (TeX-add-style-hook "dvipdf" 'TeX-PDF-mode-off LaTeX-dialect)
-  (TeX-add-style-hook "dvipdfm" 'TeX-PDF-mode-off LaTeX-dialect)
+  (TeX-add-style-hook "psfrag" #'TeX-PDF-mode-off :classopt)
+  (TeX-add-style-hook "dvipdf" #'TeX-PDF-mode-off :classopt)
+  (TeX-add-style-hook "dvipdfm" #'TeX-PDF-mode-off :classopt)
   (TeX-add-style-hook "dvipdfmx"
                      (lambda ()
-                       (setq TeX-PDF-from-DVI "Dvipdfmx"))
-                     LaTeX-dialect)
+                       (TeX-PDF-mode-on)
+                       ;; XeLaTeX normally don't use dvipdfmx
+                       ;; explicitly.
+                       (unless (eq TeX-engine 'xetex)
+                         (setq TeX-PDF-from-DVI "Dvipdfmx")))
+                     :classopt)
   ;;  (TeX-add-style-hook "DVIoutput" 'TeX-PDF-mode-off)
   ;;
   ;;  Well, DVIoutput indicates that we want to run PDFTeX and expect to
   ;;  get DVI output.  Ugh.
   (TeX-add-style-hook "ifpdf" (lambda ()
                                (TeX-PDF-mode-on)
-                               (TeX-PDF-mode-off)) LaTeX-dialect)
+                               (TeX-PDF-mode-off)) :classopt)
   ;; ifpdf indicates that we cater for either.  So calling both
   ;; functions will make sure that the default will get used unless the
   ;; user overrode it.
diff --git a/style/geometry.el b/style/geometry.el
index b7dabec..2778722 100644
--- a/style/geometry.el
+++ b/style/geometry.el
@@ -140,7 +140,8 @@ package.")
                              'function))
 
    ;; Option management
-   (if (LaTeX-provided-package-options-member "geometry" "dvipdfmx")
+   (if (and (LaTeX-provided-package-options-member "geometry" "dvipdfmx")
+           (not (eq (TeX-engine 'xetex))))
        (setq TeX-PDF-from-DVI "Dvipdfmx")))
  LaTeX-dialect)
 
diff --git a/style/graphicx.el b/style/graphicx.el
index 41ce1ec..76c9f18 100644
--- a/style/graphicx.el
+++ b/style/graphicx.el
@@ -302,7 +302,8 @@ doesn't works with Emacs 21.3 or XEmacs.  See
                              'function))
 
    ;; Option management
-   (if (LaTeX-provided-package-options-member "graphicx" "dvipdfmx")
+   (if (and (LaTeX-provided-package-options-member "graphicx" "dvipdfmx")
+           (not (eq (TeX-engine 'xetex))))
        (setq TeX-PDF-from-DVI "Dvipdfmx")))
  LaTeX-dialect)
 
diff --git a/style/hyperref.el b/style/hyperref.el
index 87ab1d8..e91225a 100644
--- a/style/hyperref.el
+++ b/style/hyperref.el
@@ -1,6 +1,6 @@
 ;;; hyperref.el --- AUCTeX style for `hyperref.sty' v6.83m
 
-;; Copyright (C) 2008, 2013--2016 Free Software Foundation, Inc.
+;; Copyright (C) 2008, 2013--2016, 2018 Free Software Foundation, Inc.
 
 ;; Author: Ralf Angeli <address@hidden>
 ;; Maintainer: address@hidden
@@ -305,6 +305,11 @@
      ;; For syntactic fontification, e.g. verbatim constructs.
      (font-latex-set-syntactic-keywords))
 
+   ;; Option management
+   (if (and (LaTeX-provided-package-options-member "hyperref" "dvipdfmx")
+            (not (eq TeX-engine 'xetex)))
+       (setq TeX-PDF-from-DVI "Dvipdfmx"))
+
    ;; Activate RefTeX reference style.
    (and LaTeX-reftex-ref-style-auto-activate
        (fboundp 'reftex-ref-style-activate)
diff --git a/tests/latex/latex-test.el b/tests/latex/latex-test.el
index 776be6c..b198eae 100644
--- a/tests/latex/latex-test.el
+++ b/tests/latex/latex-test.el
@@ -266,40 +266,58 @@ backend=biber % here is a comment
       ;; (TeX-add-style-hook "dvips"
       ;;                     (lambda ()
       ;;                       (setq TeX-PDF-from-DVI "Dvips"))
-      ;;                     LaTeX-dialect)
+      ;;                     :classopt)
       (insert "\\documentclass[dvips]{article}\n")
       (latex-mode)
-      (TeX-update-style t)
-      (should (string-equal TeX-PDF-from-DVI "Dvips"))
+      (TeX-update-style)
+      (should (equal (TeX-PDF-from-DVI) "Dvips"))
+      (should (not (member "dvips" TeX-active-styles)))
 
       ;; test for dvipdfmx option
       (erase-buffer)
       ;; This depends on the following code in latex.el:
-      ;;   (TeX-add-style-hook "dvipdfmx"
-      ;;                     (lambda ()
-      ;;                       (setq TeX-PDF-from-DVI "Dvipdfmx"))
-      ;;                     LaTeX-dialect)
+      ;; (TeX-add-style-hook "dvipdfmx"
+      ;;                     (lambda ()
+      ;;                       (TeX-PDF-mode-on)
+      ;;                       ;; XeLaTeX normally don't use dvipdfmx
+      ;;                       ;; explicitly.
+      ;;                       (unless (eq TeX-engine 'xetex)
+      ;;                         (setq TeX-PDF-from-DVI "Dvipdfmx")))
+      ;;                     :classopt)
       (insert "\\documentclass[dvipdfmx]{article}\n")
       (latex-mode)
-      (TeX-update-style t)
-      (should (string-equal TeX-PDF-from-DVI "Dvipdfmx"))
+      (TeX-update-style)
+      (should TeX-PDF-mode)
+      (should (equal (TeX-PDF-from-DVI) "Dvipdfmx"))
+      (should (not (member "dvipdfmx" TeX-active-styles)))
+
+      ;; dvipdfmx option should not trigger `TeX-PDF-from-DVI' for
+      ;; XeLaTeX document
+      (latex-mode)
+      (let ((TeX-engine 'xetex))
+       (TeX-update-style))
+      (should TeX-PDF-mode)
+      (should (not (TeX-PDF-from-DVI)))
+      (should (not (member "dvipdfmx" TeX-active-styles)))
 
       ;; test for pdftricks option
       (erase-buffer)
       ;; This depends on the following code in latex.el:
-      ;; (TeX-add-style-hook "pdftricks" 'TeX-PDF-mode-on LaTeX-dialect)
+      ;; (TeX-add-style-hook "pdftricks" #'TeX-PDF-mode-on :classopt)
       (insert "\\documentclass[pdftricks]{article}\n")
       (latex-mode)
-      (TeX-update-style t)
+      (TeX-update-style)
       (should TeX-PDF-mode)
+      (should (not (member "pdftricks" TeX-active-styles)))
 
       ;; test for psfrag option
       (erase-buffer)
       ;; This depends on the following code in latex.el:
-      ;; (TeX-add-style-hook "psfrag" 'TeX-PDF-mode-off LaTeX-dialect)
+      ;; (TeX-add-style-hook "psfrag" #'TeX-PDF-mode-off :classopt)
       (insert "\\documentclass[psfrag]{article}\n")
       (latex-mode)
-      (TeX-update-style t)
-      (should (not TeX-PDF-mode)))))
+      (TeX-update-style)
+      (should (not TeX-PDF-mode))
+      (should (not (member "psfrag" TeX-active-styles))))))
 
 ;;; latex-test.el ends here
diff --git a/tex.el b/tex.el
index 8f35924..4bf2f79 100644
--- a/tex.el
+++ b/tex.el
@@ -2841,6 +2841,8 @@ Supported values are described below:
             thereof.
 * `:plain-tex' for files in plain-TeX mode.
 * `:texinfo' for Texinfo files.
+* `:classopt' for class options of LaTeX document.  Just
+             considered as a pseudo-dialect.
 
 Purpose is notably to prevent non-Texinfo hooks to be run in
 Texinfo files, due to ambiguous style name, as this may cause bad
@@ -2902,7 +2904,8 @@ side effect e.g. on variable `TeX-font-list'.")
           (load-file el)))))
 
 (defconst TeX-style-hook-dialect-weight-alist
-  '((:latex . 1) (:texinfo . 2) (:bibtex . 4) (:plain-tex . 8) (:context . 16))
+  '((:latex . 1) (:texinfo . 2) (:bibtex . 4) (:plain-tex . 8) (:context . 16)
+    (:classopt . 32))
   "Association list to map dialects to binary weight, in order to
   implement dialect sets as bitmaps."  )
 

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

Summary of changes:
 doc/auctex.texi           | 11 +++++++++--
 latex.el                  | 50 +++++++++++++++++++++++++++++------------------
 style/empheq.el           | 12 ++++++------
 style/exam.el             |  8 +++++---
 style/geometry.el         |  3 ++-
 style/graphics.el         |  9 +++++++--
 style/graphicx.el         |  3 ++-
 style/hyperref.el         |  7 ++++++-
 style/mathtools.el        |  8 ++++----
 tests/latex/latex-test.el | 46 ++++++++++++++++++++++++++++++-------------
 tex.el                    |  5 ++++-
 11 files changed, 108 insertions(+), 54 deletions(-)


hooks/post-receive
-- 
GNU AUCTeX



reply via email to

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