[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex 0cb158fd96 21/39: Improve fontification of verba
From: |
Tassilo Horn |
Subject: |
[elpa] externals/auctex 0cb158fd96 21/39: Improve fontification of verbatim macros with braces |
Date: |
Thu, 20 Jul 2023 04:21:50 -0400 (EDT) |
branch: externals/auctex
commit 0cb158fd96ff8c1c7f0bf8c0dd152a301e82f562
Author: Arash Esbati <arash@gnu.org>
Commit: Arash Esbati <arash@gnu.org>
Improve fontification of verbatim macros with braces
* font-latex.el (font-latex-set-syntactic-keywords): Support one
level of balanced braces inside the argument of verbatim macros
with braces. See related discussion:
https://lists.gnu.org/archive/html/auctex-devel/2023-01/msg00023.html
Also handle backslash better as last character in the argument.
* tests/latex/font-latex-test.el
(font-latex-verb-macros-with-braces): New test.
---
font-latex.el | 12 +++++--
tests/latex/font-latex-test.el | 73 +++++++++++++++++++++++++++++++++++++++++-
2 files changed, 82 insertions(+), 3 deletions(-)
diff --git a/font-latex.el b/font-latex.el
index 91714b32ff..7617b5cc84 100644
--- a/font-latex.el
+++ b/font-latex.el
@@ -1097,8 +1097,16 @@ have changed."
;; Some macros take an optional argument. This is
;; the same line as above for environments.
"\\(?:\\[[^][]*\\(?:\\[[^][]*\\][^][]*\\)*\\]\\)?"
- "\\({\\).*?[^\\]\\(?:\\\\\\\\\\)*\\(}\\)")
- (1 "|") (2 "|")))))
+ ;; Within verb macros with braces, only balanced
+ ;; pairs of braces are allowed; so we respect this
+ ;; and allow one level of balanced braces. Give
+ ;; escape char(s) at the end of the verbatim
+ ;; construct punctuation syntax.
+ "\\({\\)[^}{]*?"
+ "\\(?:{[^}{]*}[^}{]*?\\)*"
+ "\\(" (regexp-quote TeX-esc) "*\\)"
+ "\\(}\\)")
+ (1 "|") (2 ".") (3 "|")))))
(when font-latex-syntactic-keywords-extra
(nconc font-latex-syntactic-keywords font-latex-syntactic-keywords-extra))
;; ;; Cater for docTeX mode.
diff --git a/tests/latex/font-latex-test.el b/tests/latex/font-latex-test.el
index 7ec3d6df51..40f9633a1a 100644
--- a/tests/latex/font-latex-test.el
+++ b/tests/latex/font-latex-test.el
@@ -1,6 +1,6 @@
;;; font-latex-test.el --- tests for font-latex -*- lexical-binding: t; -*-
-;; Copyright (C) 2020-2021 Free Software Foundation, Inc.
+;; Copyright (C) 2020-2023 Free Software Foundation, Inc.
;; This file is part of AUCTeX.
@@ -405,4 +405,75 @@ foo \"xyz\\\" bar
(search-forward "ba" nil t)
(should-not (get-text-property (point) 'face)))))
+(ert-deftest font-latex-verb-macros-with-braces ()
+ "Test fontification for verb macros with argument in braces."
+ (with-temp-buffer
+ (let ((TeX-install-font-lock #'font-latex-setup)
+ (TeX-parse-self t))
+ (insert "\
+\\documentclass{article}
+\\usepackage{fvextra}
+\\usepackage{hyperref}
+\\begin{document}
+foo \\Verb[commandchars=\\\\\\{\\}]{Pre \fbox{Middle} Post} bar
+foo \\Verb{w{o}r{k}s} bar
+foo \\Verb{b{r}eak{s}} bar
+foo \\href[ismap=false]{text \\cmd{test} text}{more text} bar
+foo \\path{C:\\path\\to\\} bar
+\\end{document}")
+ (LaTeX-mode)
+ (TeX-update-style t)
+ (syntax-ppss-flush-cache (point-min))
+ (font-lock-ensure)
+ (goto-char (point-min))
+
+ (re-search-forward "^f" nil t)
+ (should-not (get-text-property (point) 'face))
+ (search-forward "commandc")
+ (should (font-latex-faces-present-p 'font-lock-variable-name-face))
+ (search-forward "Mid")
+ (should (font-latex-faces-present-p 'font-latex-verbatim-face))
+ (search-forward "Po")
+ (should (font-latex-faces-present-p 'font-latex-verbatim-face))
+ (search-forward "ba")
+ (should-not (get-text-property (point) 'face))
+
+ (re-search-forward "^f" nil t)
+ (should-not (get-text-property (point) 'face))
+ (search-forward "k")
+ (should (font-latex-faces-present-p 'font-latex-verbatim-face))
+ (search-forward "ba")
+ (should-not (get-text-property (point) 'face))
+
+ (re-search-forward "^f" nil t)
+ (should-not (get-text-property (point) 'face))
+ (search-forward "s")
+ (should (font-latex-faces-present-p 'font-latex-verbatim-face))
+ (search-forward "ba")
+ (should-not (get-text-property (point) 'face))
+
+ (re-search-forward "^f" nil t)
+ (should-not (get-text-property (point) 'face))
+ (search-forward "ismap")
+ (should (font-latex-faces-present-p 'font-lock-variable-name-face))
+ (search-forward "text")
+ (should (font-latex-faces-present-p 'font-latex-verbatim-face))
+ (search-forward "cmd{t")
+ (should (font-latex-faces-present-p 'font-latex-verbatim-face))
+ (search-forward "text")
+ (should (font-latex-faces-present-p 'font-latex-verbatim-face))
+ (search-forward "more")
+ (should (font-latex-faces-present-p 'font-lock-constant-face))
+ (search-forward "ba")
+ (should-not (get-text-property (point) 'face))
+
+ (re-search-forward "^f" nil t)
+ (should-not (get-text-property (point) 'face))
+ (search-forward "C:")
+ (should (font-latex-faces-present-p 'font-latex-verbatim-face))
+ (search-forward "to")
+ (should (font-latex-faces-present-p 'font-latex-verbatim-face))
+ (search-forward "ba")
+ (should-not (get-text-property (point) 'face)))))
+
;;; font-latex-test.el ends here
- [elpa] externals/auctex updated (9d47b0a1bd -> 1c3360b162), Tassilo Horn, 2023/07/20
- [elpa] externals/auctex 3b38bd625b 04/39: Fontify \sloppy and \fussy, Tassilo Horn, 2023/07/20
- [elpa] externals/auctex 2017d97b0e 09/39: Rewrite *-unload-hook to *-unload-function, Tassilo Horn, 2023/07/20
- [elpa] externals/auctex 6439edca63 12/39: Clean up Texinfo mode, Tassilo Horn, 2023/07/20
- [elpa] externals/auctex c9ab5d58f3 19/39: Update style/babel.el to package version 3.88, Tassilo Horn, 2023/07/20
- [elpa] externals/auctex cdd0cbf33a 03/39: Add new style/soul.el, Tassilo Horn, 2023/07/20
- [elpa] externals/auctex 22ba857c53 06/39: Improve fontification within shortvrb delimiters, Tassilo Horn, 2023/07/20
- [elpa] externals/auctex 87e8cb0369 05/39: Simplify implementation of style/pythontex.el, Tassilo Horn, 2023/07/20
- [elpa] externals/auctex befc4a49bb 07/39: Fix style/changelog.el, Tassilo Horn, 2023/07/20
- [elpa] externals/auctex 7e420cff9b 08/39: ; * style/soul.el ("soul"): Use `LaTeX-soul-auto-cleanup'., Tassilo Horn, 2023/07/20
- [elpa] externals/auctex 0cb158fd96 21/39: Improve fontification of verbatim macros with braces,
Tassilo Horn <=
- [elpa] externals/auctex 715a88a5f2 22/39: Treat backslash in verbatim macro arguments correctly, Tassilo Horn, 2023/07/20
- [elpa] externals/auctex e1290af3e7 25/39: Remove definition of `LaTeX-label-list' in bib-cite.el, Tassilo Horn, 2023/07/20
- [elpa] externals/auctex fe42de7cf6 26/39: Obey buffer-local value of TeX-error-overview-open-after-TeX-run, Tassilo Horn, 2023/07/20
- [elpa] externals/auctex 11e9dbfdf3 30/39: Track last change for \newtheorem macro in styles, Tassilo Horn, 2023/07/20
- [elpa] externals/auctex 658340b188 32/39: Remove requiring a match during `completing-read', Tassilo Horn, 2023/07/20
- [elpa] externals/auctex 6d34e1f1ae 34/39: Simplify implementation of style/paralist.el, Tassilo Horn, 2023/07/20
- [elpa] externals/auctex d6fb3c58ce 01/39: Be more resilient when parsing arguments, Tassilo Horn, 2023/07/20
- [elpa] externals/auctex 5bfc2cb68a 11/39: Clean up ConTeXt mode, Tassilo Horn, 2023/07/20
- [elpa] externals/auctex c67f5d75b2 14/39: ; * Makefile.in (STYLESRC): Fix last change., Tassilo Horn, 2023/07/20
- [elpa] externals/auctex 93fa8bde57 17/39: Introduce new fontification keywords class "function-noarg", Tassilo Horn, 2023/07/20