comparison lisp/textmodes/tex-mode.el @ 82341:13d9a34c970a

(tex-font-lock-unfontify-region): Take tex-font-script-display into account. (tex-font-script-display, tex-font-lock-suscript): Change from a cons cell to a list of 2 elements to simplify the unfontify code.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Fri, 10 Aug 2007 04:16:21 +0000
parents b98604865ea0
children fc8dde12dd1e 424b655804ca
comparison
equal deleted inserted replaced
82340:c0011ad9af50 82341:13d9a34c970a
247 "If non-nil, fontify subscript and superscript strings." 247 "If non-nil, fontify subscript and superscript strings."
248 :type 'boolean 248 :type 'boolean
249 :group 'tex) 249 :group 'tex)
250 (put 'tex-fontify-script 'safe-local-variable 'booleanp) 250 (put 'tex-fontify-script 'safe-local-variable 'booleanp)
251 251
252 (defcustom tex-font-script-display '(-0.2 . 0.2) 252 (defcustom tex-font-script-display '(-0.2 0.2)
253 "Display specification for subscript and superscript content. 253 "Display specification for subscript and superscript content.
254 The car is used for subscript, the cdr is used for superscripts." 254 The first is used for subscript, the second is used for superscripts."
255 :group 'tex 255 :group 'tex
256 :type '(cons (choice (float :tag "Subscript") 256 :type '(list (float :tag "Subscript")
257 (const :tag "No lowering" nil)) 257 (float :tag "Superscript")))
258 (choice (float :tag "Superscript")
259 (const :tag "No raising" nil))))
260 258
261 (defvar tex-last-temp-file nil 259 (defvar tex-last-temp-file nil
262 "Latest temporary file generated by \\[tex-region] and \\[tex-buffer]. 260 "Latest temporary file generated by \\[tex-region] and \\[tex-buffer].
263 Deleted when the \\[tex-region] or \\[tex-buffer] is next run, or when the 261 Deleted when the \\[tex-region] or \\[tex-buffer] is next run, or when the
264 tex shell terminates.") 262 tex shell terminates.")
607 (while (eq (char-before pos) ?\\) 605 (while (eq (char-before pos) ?\\)
608 (setq pos (1- pos) odd (not odd))) 606 (setq pos (1- pos) odd (not odd)))
609 odd)) 607 odd))
610 (if (eq (char-after pos) ?_) 608 (if (eq (char-after pos) ?_)
611 `(face subscript display (raise ,(car tex-font-script-display))) 609 `(face subscript display (raise ,(car tex-font-script-display)))
612 `(face superscript display (raise ,(cdr tex-font-script-display)))))) 610 `(face superscript display (raise ,(cadr tex-font-script-display))))))
613 611
614 (defun tex-font-lock-match-suscript (limit) 612 (defun tex-font-lock-match-suscript (limit)
615 "Match subscript and superscript patterns up to LIMIT." 613 "Match subscript and superscript patterns up to LIMIT."
616 (when (and tex-fontify-script 614 (when (and tex-fontify-script
617 (re-search-forward "[_^] *\\([^\n\\{}]\\|\ 615 (re-search-forward "[_^] *\\([^\n\\{}]\\|\
667 (font-lock-default-unfontify-region beg end) 665 (font-lock-default-unfontify-region beg end)
668 (while (< beg end) 666 (while (< beg end)
669 (let ((next (next-single-property-change beg 'display nil end)) 667 (let ((next (next-single-property-change beg 'display nil end))
670 (prop (get-text-property beg 'display))) 668 (prop (get-text-property beg 'display)))
671 (if (and (eq (car-safe prop) 'raise) 669 (if (and (eq (car-safe prop) 'raise)
672 (member (car-safe (cdr prop)) '(-0.3 +0.3)) 670 (member (car-safe (cdr prop)) tex-font-script-display)
673 (null (cddr prop))) 671 (null (cddr prop)))
674 (put-text-property beg next 'display nil)) 672 (put-text-property beg next 'display nil))
675 (setq beg next)))) 673 (setq beg next))))
676 674
677 (defface superscript 675 (defface superscript