From: Stefan Monnier Date: Tue, 4 Oct 2005 20:45:58 +0000 (+0000) Subject: (tex-font-lock-syntactic-face-function): X-Git-Tag: emacs-pretest-22.0.90~6817 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=3307a4fa17926898746713c7cb470cd4abdff8b8;p=emacs.git (tex-font-lock-syntactic-face-function): Don't set any syntax-table property here. (tex-font-lock-verb): New function. Do it here. (tex-font-lock-syntactic-keywords): Use it. --- diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el index 5172904a78b..24267b7b8f2 100644 --- a/lisp/textmodes/tex-mode.el +++ b/lisp/textmodes/tex-mode.el @@ -631,7 +631,10 @@ An alternative value is \" . \", if you use a font with a narrow period." (,(concat "^\\(\\\\\\)end *{" verbs "}\\(.?\\)") (1 "|") (3 "<")) ;; ("^\\(\\\\\\)begin *{comment}" 1 "< b") ;; ("^\\\\end *{comment}.*\\(\n\\)" 1 "> b") - ("\\\\verb\\**\\([^a-z@*]\\)" 1 "\"")))) + ("\\\\verb\\**\\([^a-z@*]\\)" + ;; Do it last, because it uses syntax-ppss which needs the + ;; syntax-table properties of previous entries. + 1 (tex-font-lock-verb (match-end 1)))))) (defun tex-font-lock-unfontify-region (beg end) (font-lock-default-unfontify-region beg end) @@ -670,22 +673,38 @@ An alternative value is \" . \", if you use a font with a narrow period." (put 'tex-verbatim-face 'face-alias 'tex-verbatim) (defvar tex-verbatim-face 'tex-verbatim) +(defun tex-font-lock-verb (end) + "Place syntax-table properties on the \verb construct. +END is the position of the first delimiter after \verb." + (unless (nth 8 (syntax-ppss end)) + ;; Do nothing if the \verb construct is itself inside a comment or + ;; verbatim env. + (save-excursion + ;; Let's find the end and mark it. + ;; We used to do it inside tex-font-lock-syntactic-face-function, but + ;; this leads to funny effects when jumping to the end of the buffer, + ;; because font-lock applies font-lock-syntactic-keywords to the whole + ;; preceding text but font-lock-syntactic-face-function only to the + ;; actually displayed text. + (goto-char end) + (let ((char (char-before))) + (skip-chars-forward (string ?^ char)) ;; Use `end' ? + (when (eq (char-syntax (preceding-char)) ?/) + (put-text-property (1- (point)) (point) 'syntax-table '(1))) + (unless (eobp) + (put-text-property (point) (1+ (point)) 'syntax-table '(7)) + ;; Cause the rest of the buffer to be re-fontified. + ;; (remove-text-properties (1+ (point)) (point-max) '(fontified)) + ))) + "\"")) + ;; Use string syntax but math face for $...$. (defun tex-font-lock-syntactic-face-function (state) (let ((char (nth 3 state))) (cond ((not char) font-lock-comment-face) ((eq char ?$) tex-math-face) - (t - (when (char-valid-p char) - ;; This is a \verb?...? construct. Let's find the end and mark it. - (save-excursion - (skip-chars-forward (string ?^ char)) ;; Use `end' ? - (when (eq (char-syntax (preceding-char)) ?/) - (put-text-property (1- (point)) (point) 'syntax-table '(1))) - (unless (eobp) - (put-text-property (point) (1+ (point)) 'syntax-table '(7))))) - tex-verbatim-face)))) + (t tex-verbatim-face)))) (defun tex-define-common-keys (keymap)