(,(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)
(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))))
\f
(defun tex-define-common-keys (keymap)