diff options
| author | Miles Bader <miles@gnu.org> | 2005-10-07 07:15:40 +0000 |
|---|---|---|
| committer | Miles Bader <miles@gnu.org> | 2005-10-07 07:15:40 +0000 |
| commit | 00e18f33adde1d2f196fdf9cadf11235cc4fcc8f (patch) | |
| tree | 8c553c9a361da158ba47f3d0ed0429da180d957f /lisp/textmodes/tex-mode.el | |
| parent | ba4c328314c2b01e6dcc3807a0666a644c3f3954 (diff) | |
| parent | 9e1cb4bc96d36af6e8b893d467970a25afead03b (diff) | |
| download | emacs-00e18f33adde1d2f196fdf9cadf11235cc4fcc8f.tar.gz | |
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-88
Merge from emacs--cvs-trunk--0
Patches applied:
* emacs--cvs-trunk--0 (patch 569-579)
- Update from CVS
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 129-132)
- Update from CVS
- Merge from emacs--cvs-trunk--0
Diffstat (limited to 'lisp/textmodes/tex-mode.el')
| -rw-r--r-- | lisp/textmodes/tex-mode.el | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el index 23885499828..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 (characterp 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) |
