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

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

[elpa] externals/auctex 605cfc2 14/34: Add new test


From: Tassilo Horn
Subject: [elpa] externals/auctex 605cfc2 14/34: Add new test
Date: Sun, 6 Jun 2021 11:40:02 -0400 (EDT)

branch: externals/auctex
commit 605cfc2f0929f431f3ce57e57dfb2a2d8a89e4fa
Author: Ikumi Keita <ikumi@ikumi.que.jp>
Commit: Ikumi Keita <ikumi@ikumi.que.jp>

    Add new test
    
    * tests/latex/font-latex-test.el (font-latex-unclosed-dollars): New
    test.
    * font-latex.el (font-latex-find-dollar-math): Clean up doc string and
    comment.
---
 font-latex.el                  | 20 +++-----------------
 tests/latex/font-latex-test.el | 17 +++++++++++++++++
 2 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/font-latex.el b/font-latex.el
index 2b03783..da95bc2 100644
--- a/font-latex.el
+++ b/font-latex.el
@@ -1898,7 +1898,8 @@ The \\begin{equation} incl. arguments in the same line and
   "Find dollar sign(s) before LIMIT.
 Set point just before the found $. Ignore escaped $ (\"\\$\").
 Optional argument NUM, if non-nil, specifies the number of dollar
-signs to follow the point and must be 1 or 2."
+signs to follow the point and must be 1 or 2.
+LIMIT must not exceed the end of buffer."
   (catch 'found
     (while (progn
              (skip-chars-forward "^$" limit)
@@ -1916,7 +1917,7 @@ signs to follow the point and must be 1 or 2."
                    ;; inline math.  We need to consider this %$
                    ;; comments because they are the workaround for
                    ;; falsely triggered math mode due to valid,
-                   ;; non-math occurrences of $.
+                   ;; non-math occurrences of $.  (bug#48365)
                    (not num))))
         (skip-chars-forward "$" limit))
        ;; check 2: Else, is "$" escaped?
@@ -1931,21 +1932,6 @@ signs to follow the point and must be 1 or 2."
         ;; followed by $$ because expressions like "$1+1$$2+2$" and
         ;; "$1+2$$$3+3$$" are legal.
         (forward-char 1))
-       ;; (Quote from bug#19589, with a bit of adaptation)
-       ;;
-       ;; > When I use environment variables (such as $HOME) in a .tex
-       ;; > file, the $ triggers math mode syntax highlighting. The
-       ;; > result is that the rest of the buffer, until the next $,
-       ;; > is highlighted as if it were in math mode. Some examples:
-       ;; > \includegraphics{$HOME/path/to/graphic}
-       ;; > \bibliography{$HOME/path/to/bib}
-       ;;
-       ;; In order to spare workaround of adding "%$" at the end of
-       ;; the lines for such cases, we stay away from the next syntax
-       ;; state check.
-       ;; ;; check 3: Else, is "$" in comments or verb-like construct?
-       ;; ((nth 8 (syntax-ppss))
-       ;;       (skip-chars-forward "$" limit))
        (t
         ;; That "$" is live one.
         (throw 'found t))))))
diff --git a/tests/latex/font-latex-test.el b/tests/latex/font-latex-test.el
index 744ffdd..d619942 100644
--- a/tests/latex/font-latex-test.el
+++ b/tests/latex/font-latex-test.el
@@ -43,6 +43,23 @@ $a$")
               (setq font-latex--updated-region-end (point-max))
               (font-latex-match-dollar-math (point-max))))))
 
+(ert-deftest font-latex-unclosed-dollars ()
+  "Test unclosed dollar doesn't cause error."
+  (let ((TeX-install-font-lock #'font-latex-setup))
+    (with-temp-buffer
+      (LaTeX-mode)
+
+      (insert "a$")
+      (goto-char (point-min))
+      (setq font-latex--updated-region-end (point-max))
+      (should (not (font-latex-match-dollar-math (point-max))))
+
+      (erase-buffer)
+      (insert "a$$")
+      (goto-char (point-min))
+      (setq font-latex--updated-region-end (point-max))
+      (should (not (font-latex-match-dollar-math (point-max)))))))
+
 (ert-deftest font-latex-extend-region-backwards-quotation ()
   "Test f-l-e-r-b-q doesn't extend region too eagerly."
   (with-temp-buffer



reply via email to

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