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

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

[elpa] externals/auctex cd28c6f 23/57: Improve further the exclusion of


From: Tassilo Horn
Subject: [elpa] externals/auctex cd28c6f 23/57: Improve further the exclusion of reserved characters
Date: Tue, 25 Jul 2017 14:02:30 -0400 (EDT)

branch: externals/auctex
commit cd28c6f3b751c8c535b2cc3b0451a90f9430b642
Author: Arash Esbati <address@hidden>
Commit: Arash Esbati <address@hidden>

    Improve further the exclusion of reserved characters
    
    * font-latex.el (font-latex-match-simple-exclude-list): New
    variable.
    (font-latex-match-simple-command): Use
    `font-latex-match-simple-exclude-list'.  Add check for docTeX mode
    in order to remove "_" from the list.
---
 font-latex.el | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/font-latex.el b/font-latex.el
index ea3e829..dce118a 100644
--- a/font-latex.el
+++ b/font-latex.el
@@ -1782,18 +1782,30 @@ marks boundaries for searching for group ends."
              (throw 'extend group-start)))))
       nil)))
 
+(defvar font-latex-match-simple-exclude-list
+  '("-" "," "/" "&" "#" "_" "`" "'" "^" "~" "=" "." "\"")
+  "List of characters directly after \"\\\" excluded from fontification.
+Each character is a string.")
+
 (defun font-latex-match-simple-command (limit)
   "Search for command like \\foo before LIMIT."
-  ;; \s_ matches chars with symbol syntax, \sw chars with word syntax, \s. 
chars
-  ;; with punctuation syntax.  We must exclude matches where the first 
character
-  ;; after the \ is a , (thin space: foo\,bar), a - (hyphenation: foo\-bar), a 
/
-  ;; (italic correction \/) or other reserved chars like &, # or _ (\& \# \_)
+  ;; \s_ matches chars with symbol syntax, \sw chars with word syntax,
+  ;; \s. chars with punctuation syntax.  We must exclude matches where
+  ;; the first character after the \ is a reserved character and
+  ;; should not be fontified (e.g. \, in foo\,bar or \- in foo\-bar).
+  ;; These characters are stored in
+  ;; `font-latex-match-simple-exclude-list'.  In docTeX mode, we
+  ;; remove "_" from this list to get correct fontification for macros
+  ;; like `\__module_foo:nnn'
   (let* ((search (lambda ()
                   (TeX-re-search-forward-unescaped
                    "\\\\\\(\\s_\\|\\sw\\|\\s.\\)\\(?:\\s_\\|\\sw\\)*" limit 
t)))
         (pos (funcall search)))
     (while (and pos
-               (member (match-string 1) '("-" "," "/" "&" "#" "_")))
+               (member (match-string 1)
+                       (if (eq major-mode 'doctex-mode)
+                           (remove "_" font-latex-match-simple-exclude-list)
+                         font-latex-match-simple-exclude-list)))
       (setq pos (funcall search)))
     pos))
 



reply via email to

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