diff options
| author | Stefan Monnier | 2005-10-04 20:45:58 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2005-10-04 20:45:58 +0000 |
| commit | 3307a4fa17926898746713c7cb470cd4abdff8b8 (patch) | |
| tree | a39fed4cf0cf7be18a51eeb35fc08810a458a3fd | |
| parent | d315fc0fcb21be42278fc4184a68d5d749e2d537 (diff) | |
| download | emacs-3307a4fa17926898746713c7cb470cd4abdff8b8.tar.gz emacs-3307a4fa17926898746713c7cb470cd4abdff8b8.zip | |
(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.
| -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 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." | |||
| 631 | (,(concat "^\\(\\\\\\)end *{" verbs "}\\(.?\\)") (1 "|") (3 "<")) | 631 | (,(concat "^\\(\\\\\\)end *{" verbs "}\\(.?\\)") (1 "|") (3 "<")) |
| 632 | ;; ("^\\(\\\\\\)begin *{comment}" 1 "< b") | 632 | ;; ("^\\(\\\\\\)begin *{comment}" 1 "< b") |
| 633 | ;; ("^\\\\end *{comment}.*\\(\n\\)" 1 "> b") | 633 | ;; ("^\\\\end *{comment}.*\\(\n\\)" 1 "> b") |
| 634 | ("\\\\verb\\**\\([^a-z@*]\\)" 1 "\"")))) | 634 | ("\\\\verb\\**\\([^a-z@*]\\)" |
| 635 | ;; Do it last, because it uses syntax-ppss which needs the | ||
| 636 | ;; syntax-table properties of previous entries. | ||
| 637 | 1 (tex-font-lock-verb (match-end 1)))))) | ||
| 635 | 638 | ||
| 636 | (defun tex-font-lock-unfontify-region (beg end) | 639 | (defun tex-font-lock-unfontify-region (beg end) |
| 637 | (font-lock-default-unfontify-region beg end) | 640 | (font-lock-default-unfontify-region beg end) |
| @@ -670,22 +673,38 @@ An alternative value is \" . \", if you use a font with a narrow period." | |||
| 670 | (put 'tex-verbatim-face 'face-alias 'tex-verbatim) | 673 | (put 'tex-verbatim-face 'face-alias 'tex-verbatim) |
| 671 | (defvar tex-verbatim-face 'tex-verbatim) | 674 | (defvar tex-verbatim-face 'tex-verbatim) |
| 672 | 675 | ||
| 676 | (defun tex-font-lock-verb (end) | ||
| 677 | "Place syntax-table properties on the \verb construct. | ||
| 678 | END is the position of the first delimiter after \verb." | ||
| 679 | (unless (nth 8 (syntax-ppss end)) | ||
| 680 | ;; Do nothing if the \verb construct is itself inside a comment or | ||
| 681 | ;; verbatim env. | ||
| 682 | (save-excursion | ||
| 683 | ;; Let's find the end and mark it. | ||
| 684 | ;; We used to do it inside tex-font-lock-syntactic-face-function, but | ||
| 685 | ;; this leads to funny effects when jumping to the end of the buffer, | ||
| 686 | ;; because font-lock applies font-lock-syntactic-keywords to the whole | ||
| 687 | ;; preceding text but font-lock-syntactic-face-function only to the | ||
| 688 | ;; actually displayed text. | ||
| 689 | (goto-char end) | ||
| 690 | (let ((char (char-before))) | ||
| 691 | (skip-chars-forward (string ?^ char)) ;; Use `end' ? | ||
| 692 | (when (eq (char-syntax (preceding-char)) ?/) | ||
| 693 | (put-text-property (1- (point)) (point) 'syntax-table '(1))) | ||
| 694 | (unless (eobp) | ||
| 695 | (put-text-property (point) (1+ (point)) 'syntax-table '(7)) | ||
| 696 | ;; Cause the rest of the buffer to be re-fontified. | ||
| 697 | ;; (remove-text-properties (1+ (point)) (point-max) '(fontified)) | ||
| 698 | ))) | ||
| 699 | "\"")) | ||
| 700 | |||
| 673 | ;; Use string syntax but math face for $...$. | 701 | ;; Use string syntax but math face for $...$. |
| 674 | (defun tex-font-lock-syntactic-face-function (state) | 702 | (defun tex-font-lock-syntactic-face-function (state) |
| 675 | (let ((char (nth 3 state))) | 703 | (let ((char (nth 3 state))) |
| 676 | (cond | 704 | (cond |
| 677 | ((not char) font-lock-comment-face) | 705 | ((not char) font-lock-comment-face) |
| 678 | ((eq char ?$) tex-math-face) | 706 | ((eq char ?$) tex-math-face) |
| 679 | (t | 707 | (t tex-verbatim-face)))) |
| 680 | (when (char-valid-p char) | ||
| 681 | ;; This is a \verb?...? construct. Let's find the end and mark it. | ||
| 682 | (save-excursion | ||
| 683 | (skip-chars-forward (string ?^ char)) ;; Use `end' ? | ||
| 684 | (when (eq (char-syntax (preceding-char)) ?/) | ||
| 685 | (put-text-property (1- (point)) (point) 'syntax-table '(1))) | ||
| 686 | (unless (eobp) | ||
| 687 | (put-text-property (point) (1+ (point)) 'syntax-table '(7))))) | ||
| 688 | tex-verbatim-face)))) | ||
| 689 | 708 | ||
| 690 | 709 | ||
| 691 | (defun tex-define-common-keys (keymap) | 710 | (defun tex-define-common-keys (keymap) |