[Top][All Lists]

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

[elpa] externals/auctex bc47cb0 39/57: Fontify script characters with a

From: Tassilo Horn
Subject: [elpa] externals/auctex bc47cb0 39/57: Fontify script characters with a new face
Date: Wed, 11 Jan 2017 18:01:41 +0000 (UTC)

branch: externals/auctex
commit bc47cb0bb0c14e123cc7cf192be123b520ef53d2
Author: Tassilo Horn <address@hidden>
Commit: Tassilo Horn <address@hidden>

    Fontify script characters with a new face
    * doc/auctex.texi (Fontification of math): Document it.
    * doc/changes.texi: Mention that.
    * font-latex.el (font-latex-make-user-keywords): Adapt.
    (font-latex-script-char-face): New face.
    (font-latex-match-script-chars): Improve it so that double ^_ aren't
    matched because such errors were hard to see with
    font-latex-fontify-script set to invisible.
    (font-latex-script-char): New function.
 doc/auctex.texi  |    2 ++
 doc/changes.texi |    4 +++-
 font-latex.el    |   32 ++++++++++++++++++++++++++++----
 3 files changed, 33 insertions(+), 5 deletions(-)

diff --git a/doc/auctex.texi b/doc/auctex.texi
index a907fed..13661c6 100644
--- a/doc/auctex.texi
+++ b/doc/auctex.texi
@@ -2283,6 +2283,8 @@ and @i{b} would have the same font size.  If it was 3 or 
more, then
 smaller than @i{y} and @i{y} is smaller than @i{x}.
 @end defopt
+The script characters @samp{^} and @samp{_} themselves are also
+fontified with an own face named @code{font-latex-script-char-face}.
 @defopt font-latex-script-display
 Display specification for subscript and superscript content.  The car is
diff --git a/doc/changes.texi b/doc/changes.texi
index 54abc65..75daf17 100644
--- a/doc/changes.texi
+++ b/doc/changes.texi
@@ -40,7 +40,9 @@ each one raised above and a bit smaller than its basis.  For 
 feature, have a look at the customize options
 @code{font-latex-fontify-script} (especially the new values
 @code{multi-level} and @code{invisible}) and
address@hidden  Also, the script characters
address@hidden and @samp{_} are also fontified with a special face named
 @ifclear rawfile
 @xref{Fontification of math}, for details.
 @end ifclear
diff --git a/font-latex.el b/font-latex.el
index 1a52284..eed7eb9 100644
--- a/font-latex.el
+++ b/font-latex.el
@@ -820,7 +820,7 @@ Generated by `font-latex-make-user-keywords'.")))
              (1 (font-latex-script (match-beginning 0)) append))
-             (0 '(face font-latex-math-face invisible t)))))
+             (1 (font-latex-script-char (match-beginning 1)) t))))
     (add-to-list 'font-latex-keywords-2 item t)))
@@ -1156,6 +1156,22 @@ have changed."
   "Face used for subscripts."
   :group 'font-latex-highlighting-faces)
+(defface font-latex-script-char-face
+  (let ((font (cond ((assq :inherit custom-face-attributes)
+                    '(:inherit underline))
+                   (t '(:underline t)))))
+    `((((class grayscale) (background light))
+       (:foreground "DarkGray" ,@font))
+      (((class grayscale) (background dark))
+       (:foreground "gray" ,@font))
+      (((class color) (background light))
+       (:foreground "salmon"))
+      (((class color) (background dark))
+       (:foreground "DarkRed"))
+      (t (,@font))))
+  "Face used for the script chars ^ and _."
+  :group 'font-latex-highlighting-faces)
 (defface font-latex-slide-title-face
   (let* ((scale 1.2)
         (size (when (featurep 'xemacs)
@@ -1963,9 +1979,9 @@ END marks boundaries for searching for quotation ends."
 (defun font-latex-match-script-chars (limit)
-  (and (eq font-latex-fontify-script 'invisible)
-       (re-search-forward "[_^]" limit t)
-       (let ((pos (match-beginning 0)))
+  "Match subscript and superscript chars up to LIMIT."
+  (and (re-search-forward "[^_^]\\([_^]\\)" limit t)
+       (let ((pos (match-beginning 1)))
         (and (font-latex-faces-present-p 'font-latex-math-face pos)
              (not (font-latex-faces-present-p '(font-lock-constant-face
@@ -2036,6 +2052,14 @@ END marks boundaries for searching for quotation ends."
            (font-latex--get-script-props pos :super)
+(defun font-latex-script-char (pos)
+  "Return face and display spec for subscript and superscript character at 
+  (if (boundp 'font-lock-extra-managed-props)
+      `(face font-latex-script-char-face
+            ,@(when (eq font-latex-fontify-script 'invisible)
+                '(invisible t)))
+    'font-latex-script-char-face))
 ;;; docTeX
 (defvar font-latex-doctex-preprocessor-face

reply via email to

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