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. 890163e3bd40b7f2ca600


From: Tassilo Horn
Subject: [AUCTeX-diffs] GNU AUCTeX branch, master, updated. 890163e3bd40b7f2ca6007050b0db31cddfde378
Date: Tue, 3 Jan 2017 09:44:48 +0000 (UTC)

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  890163e3bd40b7f2ca6007050b0db31cddfde378 (commit)
       via  4c42f7a54dc7ab1e405a23c964eccc67cc49f359 (commit)
      from  ccec8501960a448dd8faccaae54dfd9839a37c30 (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 890163e3bd40b7f2ca6007050b0db31cddfde378
Author: Tassilo Horn <address@hidden>
Date:   Tue Jan 3 10:38:28 2017 +0100

    Bring back multi-level script font-locking
    
    * doc/auctex.texi (Fontification of math): Add documentation.
    * font-latex.el (font-latex-script-display): Increase default raise level to
    0.5.
    (font-latex-superscript-face,font-latex-subscript-face): Let scripts be a 
bit
    larger (:height 0.85 instead of 0.8).
    (font-latex--get-script-props): New function for incrementing/decrementing
    raise display property values.
    (font-latex-script): Use it.

diff --git a/doc/auctex.texi b/doc/auctex.texi
index e371899..52ecf3d 100644
--- a/doc/auctex.texi
+++ b/doc/auctex.texi
@@ -2197,13 +2197,13 @@ If non-nil, fontify subscript and superscript strings.  
Concretely, this
 means that the scripts are raised or lowered.
 
 Another possiblity is setting this variable to the symbol
address@hidden  In this case, in a formula @code{x^y^z}, y is
-raised above x, and z is raised above y.  With many script levels, the
-text might become too small to be readable.
address@hidden  In this case, in a formula @address@hidden@}}, @i{y} is
+raised above @i{x}, and @i{z} is raised above @i{y}.  With many script
+levels, the text might become too small to be readable.
 
 Lastly, you can set this variable to @code{invisible} whose behavior is
 like @code{multi-level}, and in addition the super-/subscript characters
address@hidden and @code{_} are not displayed.
address@hidden and @i{_} are not displayed.
 
 Note that this feature is not available on XEmacs, for which
 it is disabled per default.  In GNU Emacs raising and lowering is not
diff --git a/font-latex.el b/font-latex.el
index 896c6af..a5b501f 100644
--- a/font-latex.el
+++ b/font-latex.el
@@ -861,7 +861,10 @@ are equally raised over x.
 
 If this variable is set to the symbol `multi-level', then y is
 raised above x, and z is raised above y.  With many script
-levels, the text might become too small to be readable.
+levels, the text might become too small to be readable.  (The
+factors for text shrinking are defined in the faces
+`font-latex-superscript-face' and `font-latex-subscript-face' and
+the raise/lower factor in `font-latex-script-display'.)
 
 If this variable is set to the symbol `invisible', then the
 effect is essentially like `multi-level' but additionally the
@@ -875,7 +878,7 @@ script operators ^ and _ are not displayed."
        (or (TeX-booleanp val)
           (memq val '(multi-level invisible)))))
 
-(defcustom font-latex-script-display '((raise -0.3) . (raise 0.3))
+(defcustom font-latex-script-display '((raise -0.5) . (raise 0.5))
   "Display specification for subscript and superscript content.
 The car is used for subscript, the cdr is used for superscripts."
   :group 'font-latex
@@ -1118,12 +1121,12 @@ have changed."
   :group 'font-latex-highlighting-faces)
 
 (defface font-latex-superscript-face
-  '((t (:height 0.8)))
+  '((t (:height 0.85)))
   "Face used for superscripts."
   :group 'font-latex-highlighting-faces)
 
 (defface font-latex-subscript-face
-  '((t (:height 0.8)))
+  '((t (:height 0.85)))
   "Face used for subscripts."
   :group 'font-latex-highlighting-faces)
 
@@ -1951,6 +1954,15 @@ END marks boundaries for searching for quotation ends."
                       (setq pos (1- pos) odd (not odd)))
                     odd))))))
 
+(defun font-latex--get-script-props (script-type old-raise)
+  (let* ((props (copy-list (case script-type
+                            (:super (cdr font-latex-script-display))
+                            (:sub   (car font-latex-script-display)))))
+        (new-raise (plist-get props 'raise)))
+    (if old-raise
+       (plist-put props 'raise (+ old-raise new-raise))
+      props)))
+
 ;; Copy and adaption of `tex-font-lock-suscript' from tex-mode.el in
 ;; GNU Emacs on 2004-07-07.
 (defun font-latex-script (pos)
@@ -1972,15 +1984,16 @@ END marks boundaries for searching for quotation ends."
     ;; `font-lock-extra-managed-props' was introduced and serves here
     ;; for feature checking.  XEmacs (CVS and 21.4.15) currently
     ;; (2004-08-18) does not support this feature.
-    (let ((extra-props-flag (boundp 'font-lock-extra-managed-props)))
+    (let* ((extra-props-flag (boundp 'font-lock-extra-managed-props))
+          (old-raise (plist-get (get-text-property pos 'display) 'raise)))
       (if (eq (char-after pos) ?_)
          (if extra-props-flag
              `(face font-latex-subscript-face display
-                    ,(car font-latex-script-display))
+                    ,(font-latex--get-script-props :sub old-raise))
            'font-latex-subscript-face)
        (if extra-props-flag
            `(face font-latex-superscript-face display
-                  ,(cdr font-latex-script-display))
+                  ,(font-latex--get-script-props :super old-raise))
          'font-latex-superscript-face)))))
 
 ;;; docTeX

commit 4c42f7a54dc7ab1e405a23c964eccc67cc49f359
Author: Tassilo Horn <address@hidden>
Date:   Tue Jan 3 09:27:54 2017 +0100

    Revert "Remove multi-level/invisible feature of font-latex-fontify-script"
    
    This reverts commit ccec8501960a448dd8faccaae54dfd9839a37c30.

diff --git a/doc/auctex.texi b/doc/auctex.texi
index 3c3c293..e371899 100644
--- a/doc/auctex.texi
+++ b/doc/auctex.texi
@@ -2196,9 +2196,18 @@ variables @code{font-latex-fontify-script} and
 If non-nil, fontify subscript and superscript strings.  Concretely, this
 means that the scripts are raised or lowered.
 
-Note that this feature is not available on XEmacs, for which it is
-disabled per default.  In GNU Emacs raising and lowering is not enabled
-for versions 21.3 and before due to it working not properly.
+Another possiblity is setting this variable to the symbol
address@hidden  In this case, in a formula @code{x^y^z}, y is
+raised above x, and z is raised above y.  With many script levels, the
+text might become too small to be readable.
+
+Lastly, you can set this variable to @code{invisible} whose behavior is
+like @code{multi-level}, and in addition the super-/subscript characters
address@hidden and @code{_} are not displayed.
+
+Note that this feature is not available on XEmacs, for which
+it is disabled per default.  In GNU Emacs raising and lowering is not
+enabled for versions 21.3 and before due to it working not properly.
 @end defopt
 
 @defopt font-latex-script-display
diff --git a/font-latex.el b/font-latex.el
index 1e96c00..896c6af 100644
--- a/font-latex.el
+++ b/font-latex.el
@@ -810,7 +810,7 @@ Generated by `font-latex-make-user-keywords'.")))
     (add-to-list 'font-latex-keywords-1 item)
     (add-to-list 'font-latex-keywords-2 item))
   (dolist (item
-          '((font-latex-match-math-env
+          `((font-latex-match-math-env
              (0 'font-latex-warning-face t t)
              (1 'font-latex-math-face append t))
             (font-latex-match-math-envII
@@ -818,7 +818,9 @@ Generated by `font-latex-make-user-keywords'.")))
             (font-latex-match-simple-command
              (0 'font-latex-sedate-face append))
             (font-latex-match-script
-             (1 (font-latex-script (match-beginning 0)) append))))
+             (1 (font-latex-script (match-beginning 0)) append))
+            (font-latex-match-script-chars
+             (0 '(face font-latex-math-face invisible t)))))
     (add-to-list 'font-latex-keywords-2 item t)))
 (font-latex-make-user-keywords)
 
@@ -850,10 +852,28 @@ locking machinery will be triggered."
 
 (defcustom font-latex-fontify-script (not (featurep 'xemacs))
   "If non-nil, fontify subscript and superscript strings.
-This feature does not work in XEmacs."
-  :type 'boolean
+This feature does not work in XEmacs.
+
+By default, super/subscripts are raised/lowered if this variable
+is non-nil.  This fontification only affects one level of
+scripts, e.g., in x^{y^z}, the y and the z have the same size and
+are equally raised over x.
+
+If this variable is set to the symbol `multi-level', then y is
+raised above x, and z is raised above y.  With many script
+levels, the text might become too small to be readable.
+
+If this variable is set to the symbol `invisible', then the
+effect is essentially like `multi-level' but additionally the
+script operators ^ and _ are not displayed."
+  :type '(choice (boolean :tag "Enabled")
+                (const :tag "Multiple levels" multi-level)
+                (const :tag "Hide ^ and _" invisible))
   :group 'font-latex)
-(put 'font-latex-fontify-script 'safe-local-variable #'booleanp)
+(put 'font-latex-fontify-script 'safe-local-variable
+     (lambda (val)
+       (or (TeX-booleanp val)
+          (memq val '(multi-level invisible)))))
 
 (defcustom font-latex-script-display '((raise -0.3) . (raise 0.3))
   "Display specification for subscript and superscript content.
@@ -1895,11 +1915,12 @@ END marks boundaries for searching for quotation ends."
   (when (and font-latex-fontify-script
             (re-search-forward "[_^] *\\([^\n\\{}]\\|\
 \\\\\\(address@hidden|[^ \t\n]\\)\\|\\({\\)\\)" limit t))
-    (if (font-latex-faces-present-p '(font-latex-subscript-face
-                                     font-latex-superscript-face))
-       ;; Apply subscript and superscript highlighting only once in order to
-       ;; prevent the font size becoming too small.  We set an empty match to
-       ;; do that.
+    (if (and (not (memq font-latex-fontify-script '(multi-level invisible)))
+            (font-latex-faces-present-p '(font-latex-subscript-face
+                                          font-latex-superscript-face)))
+       ;; Apply subscript and superscript highlighting only once (in case
+       ;; font-latex-fontify-script is not 'multi-level) in order to prevent
+       ;; the font size becoming too small.  We set an empty match to do that.
        (let ((point (point)))
          (store-match-data (list point point point point)))
       (when (match-end 3)
@@ -1914,6 +1935,22 @@ END marks boundaries for searching for quotation ends."
                              (list beg beg beg beg))))))
     t))
 
+(defun font-latex-match-script-chars (limit)
+  (and (eq font-latex-fontify-script 'invisible)
+       (re-search-forward "[_^]" limit t)
+       (let ((pos (match-beginning 0)))
+        (and (font-latex-faces-present-p 'font-latex-math-face pos)
+             (not (font-latex-faces-present-p '(font-lock-constant-face
+                                                font-lock-builtin-face
+                                                font-lock-comment-face
+                                                font-latex-verbatim-face) pos))
+             ;; Check for backslash quoting
+             (not (let ((odd nil)
+                        (pos pos))
+                    (while (eq (char-before pos) ?\\)
+                      (setq pos (1- pos) odd (not odd)))
+                    odd))))))
+
 ;; Copy and adaption of `tex-font-lock-suscript' from tex-mode.el in
 ;; GNU Emacs on 2004-07-07.
 (defun font-latex-script (pos)

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

Summary of changes:
 doc/auctex.texi |   15 ++++++++--
 font-latex.el   |   82 ++++++++++++++++++++++++++++++++++++++++++++-----------
 2 files changed, 78 insertions(+), 19 deletions(-)


hooks/post-receive
-- 
GNU AUCTeX



reply via email to

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