auctex-diffs
[Top][All Lists]
Advanced

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

[AUCTeX-diffs] [elpa] externals/auctex 1bc2630275 20/60: Don't change sy


From: Tassilo Horn
Subject: [AUCTeX-diffs] [elpa] externals/auctex 1bc2630275 20/60: Don't change syntax of ^^A comments in doctex mode (bug#35140)
Date: Fri, 8 Apr 2022 11:52:49 -0400 (EDT)

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

    Don't change syntax of ^^A comments in doctex mode (bug#35140)
    
    * font-latex.el (font-latex-doctex-match-^^A): New function to
    override fontification on ^^A and ^^X comments with ordinary comment
    face.
    (font-latex-doctex-keywords): Add an entry to use new function.
    (font-latex-doctex-^^A): Remove.
    (font-latex-set-syntactic-keywords): Don't add entry using removed
    function.
    (font-latex--make-syntax-propertize-function): Don't use
    `font-latex-doctex-syntactic-keywords'.
    (font-latex-setup): Use forward quote instead of back quote.
    (): Update copyright year.
---
 font-latex.el | 63 +++++++++++++++++++++++++++--------------------------------
 1 file changed, 29 insertions(+), 34 deletions(-)

diff --git a/font-latex.el b/font-latex.el
index fcfdc2312c..6249d6386d 100644
--- a/font-latex.el
+++ b/font-latex.el
@@ -1,6 +1,6 @@
 ;;; font-latex.el --- LaTeX fontification for Font Lock mode.  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 1996-2021  Free Software Foundation, Inc.
+;; Copyright (C) 1996-2022  Free Software Foundation, Inc.
 
 ;; Authors:    Peter S. Galbraith <psg@debian.org>
 ;;             Simon Marshall <Simon.Marshall@esrin.esa.it>
@@ -1091,11 +1091,11 @@ have changed."
          (1 "|") (2 "|")))))
   (when font-latex-syntactic-keywords-extra
     (nconc font-latex-syntactic-keywords font-latex-syntactic-keywords-extra))
-  ;; Cater for docTeX mode.
-  (setq font-latex-doctex-syntactic-keywords
-        (append font-latex-syntactic-keywords
-                ;; For docTeX comment-in-doc.
-                '(("\\(\\^\\)\\^A" (1 (font-latex-doctex-^^A))))))
+  ;; ;; Cater for docTeX mode.
+  ;; (setq font-latex-doctex-syntactic-keywords
+  ;;       (append font-latex-syntactic-keywords
+  ;;               ;; For docTeX comment-in-doc.
+  ;;               '(("\\(\\^\\)\\^A" (1 (font-latex-doctex-^^A))))))
   ;; Finally, compute our `syntax-propertize-function' anew.
   (setq-local syntax-propertize-function
               (font-latex--make-syntax-propertize-function)))
@@ -1263,9 +1263,9 @@ triggers Font Lock to recognize the change."
 
 (defun font-latex--make-syntax-propertize-function ()
   "Return a `syntax-propertize-function' for (La|Doc)TeX documents."
-  (let ((kws (if (derived-mode-p 'doctex-mode)
-                 font-latex-doctex-syntactic-keywords
-               font-latex-syntactic-keywords)))
+  (let ((kws ;; (if (derived-mode-p 'doctex-mode)
+             ;;     font-latex-doctex-syntactic-keywords
+               font-latex-syntactic-keywords)) ;; )
     (syntax-propertize-via-font-lock kws)))
 
 ;;;###autoload
@@ -1286,7 +1286,7 @@ triggers Font Lock to recognize the change."
          `((font-latex-keywords font-latex-keywords-1 font-latex-keywords-2)
            nil nil ,font-latex-syntax-alist nil))
         (variables
-         `((font-lock-mark-block-function . mark-paragraph)
+         '((font-lock-mark-block-function . mark-paragraph)
            (font-lock-fontify-region-function
             . font-latex-fontify-region)
            (font-lock-unfontify-region-function
@@ -2250,32 +2250,27 @@ set to french, and >>german<< (and 8-bit) are used if 
set to german."
   :group 'font-latex-highlighting-faces)
 
 (defvar font-latex-doctex-keywords
-  (append font-latex-keywords-2
+  (append '((font-latex-doctex-match-^^A 0 font-lock-comment-face t))
+          font-latex-keywords-2
           '(("^%<[^>]*>" (0 font-latex-doctex-preprocessor-face t)))))
 
-;; Copy and adaptation of `doctex-font-lock-^^A' in `tex-mode.el' of
-;; CVS Emacs (March 2004)
-(defun font-latex-doctex-^^A ()
-  (if (eq (char-after (line-beginning-position)) ?\%)
-      (progn
-        (put-text-property
-         (1- (match-beginning 1)) (match-beginning 1) 'syntax-table
-         (if (= (1+ (line-beginning-position)) (match-beginning 1))
-             ;; The `%' is a single-char comment, which Emacs
-             ;; syntax-table can't deal with.  We could turn it
-             ;; into a non-comment, or use `\n%' or `%^' as the comment.
-             ;; Instead, we include it in the ^^A comment.
-             (eval-when-compile (string-to-syntax "< b"))
-           ;; FIXME: Those `eval-when-compile' shouldn't be needed any
-           ;; more since the byte-compiler will precompute those calls
-           ;; anyway (because `string-to-syntax'  is marked as pure).
-           (eval-when-compile (string-to-syntax ">"))))
-        (let ((end (line-end-position)))
-          (if (< end (point-max))
-              (put-text-property end (1+ end) 'syntax-table
-                                 (eval-when-compile
-                                   (string-to-syntax "> b")))))
-        (eval-when-compile (string-to-syntax "< b")))))
+(defun font-latex-doctex-match-^^A (limit)
+  "In docTeX mode, match comment started by ^^A and ^^X before LIMIT."
+  (catch 'found
+    (while (TeX-re-search-forward-unescaped "\\^\\^[AX]" limit t)
+      (when (eq (char-after (line-beginning-position)) ?\%)
+        (forward-line 1)
+        ;; Adjust `font-latex--updated-region-end' if necessary.
+        (let ((p (point)))
+          (if (< font-latex--updated-region-end limit)
+              (setq font-latex--updated-region-end limit))
+          (when (< font-latex--updated-region-end p)
+            (font-lock-unfontify-region
+             font-latex--updated-region-end p)
+            (setq font-latex--updated-region-end p))
+          ;; We assume that the above adjustment preserves match data.
+          (set-match-data (list (match-beginning 0) p)))
+        (throw 'found t)))))
 
 ;; Copy and adaptation of `doctex-font-lock-syntactic-face-function'
 ;; in `tex-mode.el' of CVS Emacs (March 2004)




reply via email to

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