emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/auctex 51cd5ea0bb 13/24: Improve fontification for LaTe


From: Tassilo Horn
Subject: [elpa] externals/auctex 51cd5ea0bb 13/24: Improve fontification for LaTeX kernel macros
Date: Mon, 21 Feb 2022 02:38:46 -0500 (EST)

branch: externals/auctex
commit 51cd5ea0bbf17a5ade02c1baa7a897375b1a34d7
Author: Arash Esbati <arash@gnu.org>
Commit: Arash Esbati <arash@gnu.org>

    Improve fontification for LaTeX kernel macros
    
    * font-latex.el (font-latex-built-in-keyword-classes): Add
    fontification support for LaTeX kernel macros to various keyword
    classes.
    
    * tests/latex/font-latex-test.el
    (font-latex-general-fontification): Update test for fontification.
---
 font-latex.el                  | 24 ++++++++++---
 tests/latex/font-latex-test.el | 76 +++++++++++++++++++++++++++++++++++++++---
 2 files changed, 90 insertions(+), 10 deletions(-)

diff --git a/font-latex.el b/font-latex.el
index 65f43e6809..8b1fec608d 100644
--- a/font-latex.el
+++ b/font-latex.el
@@ -240,7 +240,9 @@ variable `font-latex-fontify-sectioning'." ',num)
   '(("warning"
      ("nopagebreak" "pagebreak" "newpage" "clearpage" "cleardoublepage"
       "enlargethispage" "nolinebreak" "linebreak" "newline" "-" "\\" "\\*"
-      "appendix" "displaybreak" "allowdisplaybreaks" "tabularnewline" 
"include")
+      "appendix" "displaybreak" "allowdisplaybreaks" "tabularnewline" "include"
+      "backmatter" "frontmatter" "mainmatter"
+      "makeatletter" "makeatother" "newblock" "suppressfloats" "endinput")
      font-latex-warning-face 1 noarg)
     ("variable"
      (("setlength" "|{\\{") ("settowidth" "|{\\{") ("settoheight" "{{")
@@ -351,13 +353,23 @@ variable `font-latex-fontify-sectioning'." ',num)
       ("newcounter" "{[") ("renewenvironment" "*{[[{{")
       ("renewcommand" "*|{\\[[{") ("renewtheorem" "{[{[")
       ("usepackage" "[{[") ("fbox" "{") ("mbox" "{") ("rule" "[{{")
+      ("framebox" "|[([{") ("makebox" "|[([{") ("newsavebox" "|{\\")
+      ("parbox" "[[[{{") ("savebox" "|{\\|[([{") ("sbox" "|{\\{")
+      ("usebox" "|{\\")
+      ("cline" "{") ("extracolsep" "{") ("multicolumn" "{{{")
+      ("linethickness" "{") ("multiput" "(({{") ("put" "({")
+      ("qbezier" "[(((") ("raisebox" "{[[{")
       ("addvspace" "{") ("vspace" "*{") ("hspace" "*{")
-      ("thinspace" "")  ("negthinspace" "")
+      ("addcontentsline" "{{{") ("addtocontents" "{{")
       ("labelformat" "{{")
       ("AddToHook" "{[{") ("RemoveFromHook" "{[") ("AddToHookNext" "{{")
       ;; XXX: Should macros without arguments rather be listed in a
       ;; separate category with 'noarg instead of 'command handling?
       ("enspace" "") ("enskip" "") ("quad" "") ("qquad" "") ("nonumber" "")
+      ("bigskip" "") ("medskip" "")  ("smallskip" "")
+      ("thinspace" "")  ("negthinspace" "")
+      ("thicklines" "") ("thinlines" "")
+      ("noindent" "") ("hline" "") ("ldots" "")
       ("centering" "") ("raggedright" "") ("raggedleft" "")
       ("TeX" "") ("LaTeX" "") ("LaTeXe" "")
       ("normalfont" "") ("normalshape" "")
@@ -408,17 +420,19 @@ variable `font-latex-fontify-sectioning'." ',num)
      font-lock-type-face 2 command)
     ("bold-command"
      (("textbf" "{") ("textsc" "{") ("textssc" "{") ("textulc" "{")
-      ("textup" "{") ("textsw" "{") ("boldsymbol" "{") ("pmb" "{"))
+      ("textup" "{") ("textsw" "{") ("boldsymbol" "{") ("pmb" "{")
+      ("mathbf" "{"))
      font-latex-bold-face 1 command)
     ("italic-command"
-     (("emph" "{") ("textit" "{") ("textsl" "{"))
+     (("emph" "{") ("textit" "{") ("textsl" "{") ("mathit" "{"))
      font-latex-italic-face 1 command)
     ("math-command"
      (("ensuremath" "|{\\"))
      font-latex-math-face 1 command)
     ("type-command"
      (("texttt" "{") ("textsf" "{") ("textrm" "{") ("textmd" "{")
-      ("textnormal" "{") ("oldstylenums" "{") ("legacyoldstylenums" "{"))
+      ("textnormal" "{") ("oldstylenums" "{") ("legacyoldstylenums" "{")
+      ("mathrm" "{") ("mathsf" "{") ("mathtt" "{"))
      font-lock-type-face 1 command)
     ("bold-declaration"
      ("bf" "bfseries" "sc" "scshape" "sscshape" "ulcshape" "upshape" "swshape")
diff --git a/tests/latex/font-latex-test.el b/tests/latex/font-latex-test.el
index d619942cdf..9cc7ac527f 100644
--- a/tests/latex/font-latex-test.el
+++ b/tests/latex/font-latex-test.el
@@ -108,6 +108,7 @@ $a$")
       (insert "\
 \\documentclass[10pt]{article}
 \\begin{document}
+
 \\section{Macros}
 Inline verbatim test:  \\verb|x|
 Inline math test:      $x$, \\(x\\)
@@ -122,28 +123,46 @@ Emphasize face test:   \\emph{x}
 Declarations test:     \\ttfamily x {\\ttfamily x}
                        \\itshape  x {\\itshape x}
                        \\bfseries x {\\bfseries x}
+
 \\section{Environments}
 \\subsection{Math}
+
 \\begin{math}
   x
 \\end{math}
+
 \\[
   x
 \\]
+
 \\[x\\]
+
 \\begin{displaymath}
   x
 \\end{displaymath}
+
 \\begin{equation}
   x
 \\end{equation}
+
 \\subsection{Misc.}
+
 \\begin{verbatim}
 x
 \\end{verbatim}
+
 \\begin{description}
 \\item[x] x
 \\end{description}
+
+\\section{Box commands}
+
+\\newsavebox\\mysavebox
+\\savebox{\\mysavebox}[30mm][r]{This is my box}
+\\savebox{\\mysavebox}(0,0)[l]{This is my box}
+
+\\parbox[m][3cm][c]{2cm}{Some Text}
+
 \\end{document}
 
 %%% Local Variables:
@@ -155,7 +174,7 @@ x
       (goto-char (point-min))
 
       ;; Test for \documentclass:
-      (search-forward-regexp "\\\\document\\(?1:c\\)lass\\[")
+      (re-search-forward "\\\\document\\(?1:c\\)lass\\[")
       (should (font-latex-faces-present-p 'font-lock-keyword-face
                                           (match-beginning 1)))
       (forward-char)
@@ -168,7 +187,7 @@ x
       (end-of-line)
 
       ;; Test for \section macro itself:
-      (search-forward-regexp "\\\\sec\\(?1:t\\)ion{")
+      (re-search-forward "\\\\sec\\(?1:t\\)ion{")
       (should (font-latex-faces-present-p 'font-lock-keyword-face
                                           (match-beginning 1)))
       (goto-char (match-end 0))
@@ -233,7 +252,7 @@ x
       (end-of-line)
 
       ;; Test for math environments:
-      (search-forward-regexp "\\\\be\\(?1:g\\)in{ma\\(?2:t\\)h}")
+      (re-search-forward "\\\\be\\(?1:g\\)in{ma\\(?2:t\\)h}")
       (should (font-latex-faces-present-p 'font-lock-keyword-face
                                           (match-beginning 1)))
       (should (font-latex-faces-present-p 'font-lock-function-name-face
@@ -271,11 +290,58 @@ x
       (LaTeX-find-matching-end)
 
       ;; Check the fontification of \item macro itself:
-      (search-forward-regexp "\\\\it\\(?1:e\\)m\\[")
+      (re-search-forward "\\\\it\\(?1:e\\)m\\[")
       (should (font-latex-faces-present-p 'font-lock-keyword-face
                                           (match-beginning 1)))
       ;; Now for the optional argument:
       (should (font-latex-faces-present-p 'font-lock-variable-name-face))
-      (LaTeX-find-matching-end)  )))
+      (LaTeX-find-matching-end)
+
+      ;; Test for boxing commands
+      (re-search-forward "\\\\news\\(?1:a\\)vebox")
+      (should (font-latex-faces-present-p 'font-lock-keyword-face
+                                          (match-beginning 1)))
+      (re-search-forward "\\\\mys\\(?1:a\\)vebox")
+      (should (font-latex-faces-present-p 'font-lock-function-name-face
+                                          (match-beginning 1)))
+      ;; Test for the fontification in braces '{\mysavebox}':
+      (re-search-forward "{\\\\mys\\(?1:a\\)ve")
+      (should (font-latex-faces-present-p 'font-lock-function-name-face
+                                          (match-beginning 1)))
+      ;; Now for the optionals arguments of '\savebox':
+      (re-search-forward "\\[\\(?1:[^]]+\\)\\]\\[\\(?2:[^]]+\\)\\]{")
+      (should (font-latex-faces-present-p 'font-lock-variable-name-face
+                                          (match-beginning 1)))
+      (should (font-latex-faces-present-p 'font-lock-variable-name-face
+                                          (match-beginning 2)))
+      (should (font-latex-faces-present-p 'font-lock-function-name-face
+                                          (match-end 0)))
+      (end-of-line)
+
+      ;; Test for the optional arguments of '\savebox' which look
+      ;; different for 'picture' environments:
+      (re-search-forward "(\\(?1:.\\),\\(?2:.\\))\\[\\(?3:[^]]+\\)\\]{")
+      (should (font-latex-faces-present-p 'font-lock-variable-name-face
+                                          (match-beginning 1)))
+      (should (font-latex-faces-present-p 'font-lock-variable-name-face
+                                          (match-beginning 2)))
+      (should (font-latex-faces-present-p 'font-lock-variable-name-face
+                                          (match-beginning 3)))
+      (should (font-latex-faces-present-p 'font-lock-function-name-face
+                                          (match-end 0)))
+
+      ;; Test for \parbox and its arguments:
+      (re-search-forward
+       
"\\\\p\\(?1:a\\)rbox\\[\\(?2:[^]]+\\)\\]\\[\\(?3:[^]]+\\)\\]\\[\\(?4:[^]]+\\)\\]{")
+      (should (font-latex-faces-present-p 'font-lock-keyword-face
+                                          (match-beginning 1)))
+      (should (font-latex-faces-present-p 'font-lock-variable-name-face
+                                          (match-beginning 2)))
+      (should (font-latex-faces-present-p 'font-lock-variable-name-face
+                                          (match-beginning 3)))
+      (should (font-latex-faces-present-p 'font-lock-variable-name-face
+                                          (match-beginning 4)))
+      (should (font-latex-faces-present-p 'font-lock-function-name-face
+                                          (match-end 0)))  )))
 
 ;;; font-latex-test.el ends here



reply via email to

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