auctex-diffs
[Top][All Lists]
Advanced

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

[AUCTeX-diffs] GNU AUCTeX branch, master, updated. e21d071e52cbdf2382c06


From: Arash Esbati
Subject: [AUCTeX-diffs] GNU AUCTeX branch, master, updated. e21d071e52cbdf2382c0636aa723354df9e2983a
Date: Wed, 10 May 2017 01:59:08 -0400 (EDT)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU AUCTeX".

The branch, master has been updated
       via  e21d071e52cbdf2382c0636aa723354df9e2983a (commit)
       via  cd28c6f3b751c8c535b2cc3b0451a90f9430b642 (commit)
      from  f4723786f2d2ec58bdb94bd8112f6437f33c1d36 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit e21d071e52cbdf2382c0636aa723354df9e2983a
Author: Arash Esbati <address@hidden>
Date:   Wed May 10 07:58:03 2017 +0200

    Exclude arguments to math environments from fontification
    
    * font-latex.el (font-latex-match-math-envII)
    (font-latex-extend-region-backwards-math-envII): Match and exclude
    optional and mandatory argument(s) to math environments from
    fontification.

diff --git a/font-latex.el b/font-latex.el
index dce118a..e4f9713 100644
--- a/font-latex.el
+++ b/font-latex.el
@@ -1871,18 +1871,30 @@ END marks boundaries for searching for environment 
ends."
 Used for patterns like:
 \\begin{equation}
  fontified stuff
-\\end{equation}
-The \\begin{equation} and \\end{equation} are not fontified here."
+\\end{equation} or
+\\begin{empheq}[X=Y\\Rightarrow]{alignat=3}
+ fontified stuff
+\\end{empheq}
+The \\begin{equation} incl. arguments in the same line and
+\\end{equation} are not fontified here."
   (when (re-search-forward (concat "\\\\begin[ \t]*{"
                                   (regexp-opt font-latex-math-environments t)
-                                  "\\*?}")
+                                  ;; Subexpression 2 is used to build
+                                  ;; the \end{<env>} construct below
+                                  "\\(\\*?}\\)"
+                                  ;; Match an optional and possible
+                                  ;; mandatory argument(s) as long as
+                                  ;; they are on the same line with
+                                  ;; no spaces in-between
+                                  
"\\(?:\\[[^][]*\\(?:\\[[^][]*\\][^][]*\\)*\\]\\)?"
+                                  "\\(?:{[^}]*}\\)*")
                           limit t)
     (let ((beg (match-end 0)) end)
       (if (re-search-forward (concat "\\\\end[ \t]*{"
                                     (regexp-quote
                                      (buffer-substring-no-properties
                                       (match-beginning 1)
-                                      (match-end 0))))
+                                      (match-end 2))))
                             ;; XXX: Should this rather be done by
                             ;; extending the region to be fontified?
                             (+ limit font-latex-multiline-boundary) 'move)
@@ -1905,11 +1917,16 @@ END marks boundaries for searching for environment 
ends."
              (concat "\\\\end[ \t]*{"
                      (regexp-opt font-latex-math-environments t)
                      "\\*?}") beg t)
-       (when (and (re-search-backward (concat  "\\\\begin[ \t]*{"
-                                               (buffer-substring-no-properties
-                                                (match-beginning 1)
-                                                (match-end 0)))
-                                      (- beg font-latex-multiline-boundary) t)
+       (when (and (re-search-backward
+                   (concat  "\\\\begin[ \t]*{"
+                            (buffer-substring-no-properties
+                             (match-beginning 1)
+                             (match-end 0))
+                            ;; Match an optional and possible
+                            ;; mandatory argument(s)
+                            "\\(?:\\[[^][]*\\(?:\\[[^][]*\\][^][]*\\)*\\]\\)?"
+                            "\\(?:{[^}]*}\\)*")
+                   (- beg font-latex-multiline-boundary) t)
                   (< (point) beg))
          (throw 'extend (point))))
       nil)))

commit cd28c6f3b751c8c535b2cc3b0451a90f9430b642
Author: Arash Esbati <address@hidden>
Date:   Mon May 8 10:42:52 2017 +0200

    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.

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))
 

-----------------------------------------------------------------------

Summary of changes:
 font-latex.el | 57 +++++++++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 43 insertions(+), 14 deletions(-)


hooks/post-receive
-- 
GNU AUCTeX



reply via email to

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