[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex d2b0547 16/67: Fix not to run wrong style hooks
From: |
Tassilo Horn |
Subject: |
[elpa] externals/auctex d2b0547 16/67: Fix not to run wrong style hooks |
Date: |
Fri, 8 Feb 2019 11:40:31 -0500 (EST) |
branch: externals/auctex
commit d2b054747a3a2e8244d89101dfaaa1110607fe2c
Author: Ikumi Keita <address@hidden>
Commit: Ikumi Keita <address@hidden>
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'.
---
doc/auctex.texi | 11 +++++++++--
latex.el | 41 ++++++++++++++++++++++++++---------------
style/geometry.el | 3 ++-
style/graphicx.el | 3 ++-
style/hyperref.el | 7 ++++++-
tests/latex/latex-test.el | 46 ++++++++++++++++++++++++++++++++--------------
tex.el | 5 ++++-
7 files changed, 81 insertions(+), 35 deletions(-)
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." )
- [elpa] externals/auctex 12f7a21 18/67: Add suggestions for non-privileged installation, (continued)
- [elpa] externals/auctex 12f7a21 18/67: Add suggestions for non-privileged installation, Tassilo Horn, 2019/02/08
- [elpa] externals/auctex 8b5e53d 24/67: Remove unnecessary parentheses, Tassilo Horn, 2019/02/08
- [elpa] externals/auctex 667f4e9 17/67: Defer running style hook until options are given actually, Tassilo Horn, 2019/02/08
- [elpa] externals/auctex 48d5874 32/67: Use `write-file-functions', Tassilo Horn, 2019/02/08
- [elpa] externals/auctex a20430d 15/67: Add new style/dashundergaps.el, Tassilo Horn, 2019/02/08
- [elpa] externals/auctex ff75757 21/67: Remove references to older emacsens in comments and doc strings, Tassilo Horn, 2019/02/08
- [elpa] externals/auctex 253e900 25/67: Adjust autoload cookie, Tassilo Horn, 2019/02/08
- [elpa] externals/auctex 4617caa 26/67: Remove compatibility code for older emacsen, Tassilo Horn, 2019/02/08
- [elpa] externals/auctex b13bebb 28/67: Remove compatibility code for older emacsen, Tassilo Horn, 2019/02/08
- [elpa] externals/auctex 7030681 29/67: * tex-buf.el (TeX-special-mode): Use `define-derived-mode'., Tassilo Horn, 2019/02/08
- [elpa] externals/auctex d2b0547 16/67: Fix not to run wrong style hooks,
Tassilo Horn <=
- [elpa] externals/auctex 0a05b39 22/67: Use `declare-function' without `fboundp' test, Tassilo Horn, 2019/02/08
- [elpa] externals/auctex 6610f48 42/67: ; Silence the compiler in styles for `font-latex-add-to-syntax-alist', Tassilo Horn, 2019/02/08
- [elpa] externals/auctex 5551227 30/67: Remove XEmacs compatibility code in tex-bar.el, Tassilo Horn, 2019/02/08
- [elpa] externals/auctex 993326c 40/67: ; Silence the compiler in styles for `font-latex-syntactic-keywords-extra', Tassilo Horn, 2019/02/08
- [elpa] externals/auctex a4576a1 49/67: ; * tex.el (TeX-math-toggle-off-input-method): Fix doc string., Tassilo Horn, 2019/02/08
- [elpa] externals/auctex 9c42b43 52/67: Use ASCII apostrophe in code expample, Tassilo Horn, 2019/02/08
- [elpa] externals/auctex 49c71f9 44/67: ; Silence the compiler in styles for `LaTeX-x?color-definecolor-list', Tassilo Horn, 2019/02/08
- [elpa] externals/auctex 4fed4a7 64/67: Remove combatibility code for older emasen, Tassilo Horn, 2019/02/08
- [elpa] externals/auctex de3b5f7 47/67: ; * doc/preview-latex.texi (preview-cache-preamble): Use @url{}., Tassilo Horn, 2019/02/08
- [elpa] externals/auctex 449ec06 43/67: ; Silence the compiler in styles for `reftex-compile-variables', Tassilo Horn, 2019/02/08