From 587043f8b7201a09b5839a1a9c77984890e52d51 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 17 Apr 2006 12:05:40 +0000 Subject: (tex-font-lock-match-suscript): New function. (tex-font-lock-keywords-3): Use it. --- lisp/textmodes/tex-mode.el | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'lisp/textmodes/tex-mode.el') diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el index 97153e31a25..0b0d60242bc 100644 --- a/lisp/textmodes/tex-mode.el +++ b/lisp/textmodes/tex-mode.el @@ -594,20 +594,24 @@ An alternative value is \" . \", if you use a font with a narrow period." '(face subscript display (raise -0.3)) '(face superscript display (raise +0.3))))) +(defun tex-font-lock-match-suscript (limit) + "Match subscript and superscript patterns up to LIMIT." + (when (re-search-forward "[_^] *\\([^\n\\{}]\\|\ +\\\\\\([a-zA-Z@]+\\|[^ \t\n]\\)\\|{[^\\{]*}\\|\\({\\)\\)" limit t) + (when (match-end 3) + (let ((beg (match-beginning 3)) + (end (save-restriction + (narrow-to-region (point-min) limit) + (condition-case nil (scan-lists (point) 1 1) (error nil))))) + (store-match-data (if end + (list (match-beginning 0) end beg end)) + (list beg beg beg beg)))) + t)) + (defconst tex-font-lock-keywords-3 (append tex-font-lock-keywords-2 - (eval-when-compile - (let ((general "\\([a-zA-Z@]+\\|[^ \t\n]\\)") - (slash "\\\\") - ;; This is not the same regexp as before: it has a `+' removed. - ;; The + makes the matching faster in the above cases (where we can - ;; exit as soon as the match fails) but would make this matching - ;; degenerate to nasty complexity (because we try to match the - ;; closing brace, which forces trying all matching combinations). - (arg "{\\(?:[^{}\\]\\|\\\\.\\|{[^}]*}\\)*")) - `((,(concat "[_^] *\\([^\n\\{}#]\\|" slash general "\\|#[0-9]\\|" arg "}\\)") - (1 (tex-font-lock-suscript (match-beginning 0)) - append)))))) + '((tex-font-lock-match-suscript + (1 (tex-font-lock-suscript (match-beginning 0)) append)))) "Experimental expressions to highlight in TeX modes.") (defvar tex-font-lock-keywords tex-font-lock-keywords-1 -- cgit v1.2.3 From 43c50d22bc75543e5577f036fcd957162daf7086 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 17 Apr 2006 13:44:56 +0000 Subject: (tex-font-lock-match-suscript): Paren typo. --- lisp/textmodes/tex-mode.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lisp/textmodes/tex-mode.el') diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el index 0b0d60242bc..8ca7c3026e8 100644 --- a/lisp/textmodes/tex-mode.el +++ b/lisp/textmodes/tex-mode.el @@ -604,8 +604,8 @@ An alternative value is \" . \", if you use a font with a narrow period." (narrow-to-region (point-min) limit) (condition-case nil (scan-lists (point) 1 1) (error nil))))) (store-match-data (if end - (list (match-beginning 0) end beg end)) - (list beg beg beg beg)))) + (list (match-beginning 0) end beg end) + (list beg beg beg beg))))) t)) (defconst tex-font-lock-keywords-3 -- cgit v1.2.3