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. 22d2eb6a33718053d12b1


From: Ikumi Keita
Subject: [AUCTeX-diffs] GNU AUCTeX branch, master, updated. 22d2eb6a33718053d12b1887b123fca68ae02f36
Date: Wed, 17 Jun 2020 03:40:06 -0400 (EDT)

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  22d2eb6a33718053d12b1887b123fca68ae02f36 (commit)
      from  0079026a7c0aa5ca0f9b22b0af65436e6675e3c3 (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 22d2eb6a33718053d12b1887b123fca68ae02f36
Author: Ikumi Keita <ikumi@ikumi.que.jp>
Date:   Tue Jun 16 17:59:07 2020 +0900

    Use constant regexp to fontify math environments
    
    * font-latex.el (font-latex--match-math-envII-regexp): New internal
    variable to store regexp to search math environments such as
    "equation".
    (font-latex-match-math-envII): Use it.
    (font-latex--update-math-env): New function to update
    `font-latex-math-environments' and build
    `font-latex--match-math-envII-regexp' from it.
    (font-latex-math-environments-from-texmathp): Remove.
    (font-latex-math-environments): Change default value to nil and
    initialize at top level by new function.
    * style/breqn.el:
    * style/empheq.el:
    * style/mathtools.el:
    Arrange in accord with the above change.
    * style/amsmath.el:
    Arrange in accord with the above change.
    Add fontification rule for \boxed{}.
    * doc/auctex.texi:
    Add instruction to convert customization.

diff --git a/doc/auctex.texi b/doc/auctex.texi
index 4886840..ab69dd0 100644
--- a/doc/auctex.texi
+++ b/doc/auctex.texi
@@ -12,7 +12,7 @@ This manual is for @AUCTeX{}
 (version @value{VERSION} from @value{UPDATED}),
 a sophisticated TeX environment for Emacs.
 
-Copyright @copyright{} 1992-1995, 2001, 2002, 2004-2019
+Copyright @copyright{} 1992-1995, 2001, 2002, 2004-2020
 Free Software Foundation, Inc.
 
 @quotation
@@ -2274,6 +2274,13 @@ recommended to customize 
@code{font-latex-math-environments}, which
 is initialized according to @code{texmathp-tex-commands} and
 @code{texmathp-tex-commands-default} by default.
 
+To convert your customization in @code{font-latex-math-environments}
+into @code{texmathp-tex-commands}, please register your own math
+environments, together with starred variants if any, as entries of
+@code{env-on} type in @code{texmathp-tex-commands}, then clear out
+@code{font-latex-math-environments}. You have to restart Emacs for this
+new customization to take effect for fontification.
+
 In order to make math constructs more readable, @fontlatex{} displays
 subscript and superscript parts in a smaller font and raised or lowered
 respectively.  This fontification feature can be controlled with the
diff --git a/font-latex.el b/font-latex.el
index ad2153f..984771d 100644
--- a/font-latex.el
+++ b/font-latex.el
@@ -1768,31 +1768,52 @@ Used for patterns like:
          (throw 'match t))))))
 
 (require 'texmathp)
-(defun font-latex-math-environments-from-texmathp (list)
-  "Return list of math environments extracted from LIST.
-Utility to share data with texmathp.el.
-LIST should have the same structure as `texmathp-tex-commands'.
-Return list of environment names marked as `env-on' type in LIST,
-except starred forms."
-  (let (result)
-    (dolist (entry list)
-      (if (and (eq 'env-on (cadr entry))
-              (not (string= "*" (substring (car entry) -1))))
-         (push (car entry) result)))
-    result))
-
-(defcustom font-latex-math-environments
-  (font-latex-math-environments-from-texmathp texmathp-tex-commands1)
+(defcustom font-latex-math-environments nil
   "List of math environment names for font locking.
 It is no longer recommended to customize this option. You should
-customize `texmathp-tex-commands' instead because it is important for
-stable operation of font lock that this option is coherent with that
-option in addition to `texmathp-tex-commands-default'.
-Actually, the default value of this option is now taken from those
-variables."
+customize `texmathp-tex-commands' instead because it is important
+for stable operation of font lock that this option is coherent
+with that option in addition to `texmathp-tex-commands-default'.
+See info node `(auctex)Fontification of math' to convert your
+customization into `texmathp-tex-commands'."
+  ;; This option is now used only through
+  ;; `font-latex--match-math-envII-regexp'.
   :type '(repeat string)
   :group 'font-latex)
 
+(defvar font-latex--match-math-envII-regexp nil
+  "Regular expression to match math environments.
+Set by `font-latex--update-math-env' and used in
+`font-latex-match-math-envII'.")
+
+(defun font-latex--update-math-env (list)
+  "Update variables for font locking of math environments by LIST.
+Helper function for style files such as amsmath.el.
+LIST should have the same structure as `texmathp-tex-commands'.
+Extract environments marked as `env-on' in LIST and add them to
+`font-latex-math-environments', except starred variants. Then
+update `font-latex--match-math-envII-regexp'."
+  (dolist (entry list)
+    (if (and (eq 'env-on (cadr entry))
+            (not (string= "*" (substring (car entry) -1))))
+       ;; Just push since we no longer need to care the order of entries.
+       (cl-pushnew (car entry) font-latex-math-environments :test #'equal)))
+  (setq font-latex--match-math-envII-regexp
+       (concat "\\\\begin[ \t]*{"
+               (regexp-opt font-latex-math-environments t)
+               ;; Subexpression 2 is used to build the \end{<env>}
+               ;; construct later.
+               "\\(\\*?}\\)"
+               ;; Match an optional and possible mandatory
+               ;; argument(s) as long as they are on the same line
+               ;; with no spaces in-between. The content of optinal
+               ;; argument can span multiple lines.
+               "\\(?:\\[[^][]*\\(?:\\[[^][]*\\][^][]*\\)*\\]\\)?"
+               "\\(?:{[^}]*}\\)*")))
+
+;; Initialize.
+(font-latex--update-math-env texmathp-tex-commands1)
+
 (defun font-latex-match-math-envII (limit)
   "Match math patterns up to LIMIT.
 Used for patterns like:
@@ -1804,17 +1825,7 @@ Used for patterns like:
 \\end{empheq}
 The \\begin{equation} incl. arguments in the same line and
 \\end{equation} are not fontified here."
-  (when (re-search-forward (concat "\\\\begin[ \t]*{"
-                                  (regexp-opt font-latex-math-environments t)
-                                  ;; Subexpression 2 is used to build
-                                  ;; the \end{<env>} construct below
-                                  "\\(\\*?}\\)"
-                                  ;; Match an optional and possible
-                                  ;; mandatory argument(s). They can
-                                  ;; span multiple lines.
-                                  
"\\(?:\\[[^][]*\\(?:\\[[^][]*\\][^][]*\\)*\\]\\)?"
-                                  "\\(?:{[^}]*}\\)*")
-                          limit t)
+  (when (re-search-forward font-latex--match-math-envII-regexp limit t)
     (let ((beg (match-end 0)) end
          (beg-of-begin (match-beginning 0)))
       (if (re-search-forward (concat "\\\\end[ \t]*{"
diff --git a/style/amsmath.el b/style/amsmath.el
index ebf651e..a31d1c1 100644
--- a/style/amsmath.el
+++ b/style/amsmath.el
@@ -30,8 +30,11 @@
 
 ;;; Code:
 
-(defvar font-latex-math-environments)
-(declare-function font-latex-math-environments-from-texmathp
+;; Fontification
+(declare-function font-latex-add-keywords
+                 "font-latex"
+                 (keywords class))
+(declare-function font-latex--update-math-env
                  "font-latex" (list))
 (require 'texmathp)
 (let ((list '(("equation*"     env-on)
@@ -44,13 +47,11 @@
              ("xxalignat"     env-on) ("\\boxed"       arg-on)
              ("\\text"        arg-off) ("\\intertext"   arg-off))))
   (dolist (entry list)
-    (add-to-list 'texmathp-tex-commands-default entry t))
+    (add-to-list 'texmathp-tex-commands-default entry))
   (texmathp-compile)
   (when (and (featurep 'font-latex)
             (eq TeX-install-font-lock 'font-latex-setup))
-    (dolist (entry (font-latex-math-environments-from-texmathp list))
-      ;; Append our addition so that we don't interfere with user 
customizations
-      (add-to-list 'font-latex-math-environments entry t))))
+    (font-latex--update-math-env list)))
 
 (TeX-add-style-hook
  "amsmath"
@@ -195,7 +196,12 @@
    ;; is non-nil
    (and LaTeX-reftex-ref-style-auto-activate
        (fboundp 'reftex-ref-style-activate)
-       (reftex-ref-style-activate "AMSmath")))
+       (reftex-ref-style-activate "AMSmath"))
+
+   (when (and (featurep 'font-latex)
+             (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(("boxed" "{"))
+                             'math-command)))
  LaTeX-dialect)
 
 (defun LaTeX-amsmath-env-alignat (env)
diff --git a/style/breqn.el b/style/breqn.el
index 91d69d0..36eb78d 100644
--- a/style/breqn.el
+++ b/style/breqn.el
@@ -95,9 +95,8 @@ Keys offered for key=val query depend on ENV.  \"label\" and
 
 (add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
 
-(defvar font-latex-math-environments)
-(declare-function font-latex-math-environments-from-texmathp
-                 "font-latex" (list))
+;; Fontification
+(declare-function font-latex--update-math-env "font-latex" (list))
 (require 'texmathp)
 (let ((list '(("dmath"         env-on) ("dmath*"        env-on)
              ("dseries"       env-on) ("dseries*"      env-on)
@@ -105,13 +104,11 @@ Keys offered for key=val query depend on ENV.  \"label\" 
and
              ("darray"        env-on) ("darray*"       env-on)
              ("dsuspend"      env-off))))
   (dolist (entry list)
-    (add-to-list 'texmathp-tex-commands-default entry t))
+    (add-to-list texmathp-tex-commands-default entry))
   (texmathp-compile)
   (when (and (featurep 'font-latex)
             (eq TeX-install-font-lock 'font-latex-setup))
-    ;; Append our addition so that we don't interfere with user customizations
-    (dolist (entry (font-latex-math-environments-from-texmathp list))
-      (add-to-list 'font-latex-math-environments entry t))))
+    (font-latex--update-math-env list)))
 
 (TeX-add-style-hook
  "breqn"
diff --git a/style/empheq.el b/style/empheq.el
index aacd6e7..e8b5b51 100644
--- a/style/empheq.el
+++ b/style/empheq.el
@@ -41,14 +41,13 @@
 (declare-function font-latex-add-keywords
                  "font-latex"
                  (keywords class))
-(declare-function font-latex-math-environments-from-texmathp
+(declare-function font-latex--update-math-env
                  "font-latex" (list))
 
 (declare-function LaTeX-item-equation-alignat
                  "amsmath" (&optional suppress))
 
 (defvar LaTeX-mathtools-package-options)
-(defvar font-latex-math-environments)
 
 (defvar LaTeX-empheq-key-val-options
   `(("box")
@@ -277,6 +276,7 @@ number of ampersands if possible."
       (save-excursion
        (insert (make-string (+ ncols ncols -1) ?&))))))
 
+;; Fontification
 (require 'texmathp)
 (let ((list '(("empheq"        env-on)
              ;; XXX: Should we add the remaining entries only when
@@ -288,13 +288,11 @@ number of ampersands if possible."
              ("AmSflalign"    env-on) ("AmSflalign*"   env-on)
              ("AmSalignat"    env-on) ("AmSalignat*"   env-on))))
   (dolist (entry list)
-    (add-to-list 'texmathp-tex-commands-default entry t))
+    (cl-pushnew entry texmathp-tex-commands-default :test #'equal))
   (texmathp-compile)
   (when (and (featurep 'font-latex)
             (eq TeX-install-font-lock 'font-latex-setup))
-    ;; Append our addition so that we don't interfere with user customizations
-    (dolist (entry (font-latex-math-environments-from-texmathp list))
-      (add-to-list 'font-latex-math-environments entry t))))
+    (font-latex--update-math-env list)))
 
 (TeX-add-style-hook
  "empheq"
diff --git a/style/mathtools.el b/style/mathtools.el
index 03a0f9b..f0fb744 100644
--- a/style/mathtools.el
+++ b/style/mathtools.el
@@ -235,6 +235,7 @@ Put line break macro on the last line.  Next, insert an 
ampersand."
   (save-excursion
     (insert ?&)))
 
+;; Fontification
 (require 'texmathp)
 (add-to-list 'texmathp-tex-commands-default
             '("\\shortintertext" arg-off) t)

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

Summary of changes:
 doc/auctex.texi    |  9 ++++++-
 font-latex.el      | 73 +++++++++++++++++++++++++++++++-----------------------
 style/amsmath.el   | 20 +++++++++------
 style/breqn.el     | 11 +++-----
 style/empheq.el    | 10 +++-----
 style/mathtools.el |  1 +
 6 files changed, 72 insertions(+), 52 deletions(-)


hooks/post-receive
-- 
GNU AUCTeX



reply via email to

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