diff options
| author | Stefan Monnier | 2004-10-10 01:51:34 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2004-10-10 01:51:34 +0000 |
| commit | 1f4cc034320bca5b4a8e6e69da8553ba33d36a8d (patch) | |
| tree | 908b95189aa0a176000210869be02e0e125b2f7d /lisp/textmodes | |
| parent | fdbc4dea48258bbb7b5d38877fbeaf911deea454 (diff) | |
| download | emacs-1f4cc034320bca5b4a8e6e69da8553ba33d36a8d.tar.gz emacs-1f4cc034320bca5b4a8e6e69da8553ba33d36a8d.zip | |
(tex-font-lock-append-prop): New fun.
(tex-font-lock-keywords-2): Use it.
(tex-font-lock-syntactic-keywords): Fix the `verbatim' treatment.
Diffstat (limited to 'lisp/textmodes')
| -rw-r--r-- | lisp/textmodes/tex-mode.el | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el index 2a9059e2f56..ddcaaa0bf4f 100644 --- a/lisp/textmodes/tex-mode.el +++ b/lisp/textmodes/tex-mode.el | |||
| @@ -500,6 +500,11 @@ An alternative value is \" . \", if you use a font with a narrow period." | |||
| 500 | 1 font-lock-function-name-face)))) | 500 | 1 font-lock-function-name-face)))) |
| 501 | "Subdued expressions to highlight in TeX modes.") | 501 | "Subdued expressions to highlight in TeX modes.") |
| 502 | 502 | ||
| 503 | (defun tex-font-lock-append-prop (prop) | ||
| 504 | (unless (memq (get-text-property (match-end 1) 'face) | ||
| 505 | '(font-lock-comment-face tex-verbatim-face)) | ||
| 506 | prop)) | ||
| 507 | |||
| 503 | (defconst tex-font-lock-keywords-2 | 508 | (defconst tex-font-lock-keywords-2 |
| 504 | (append tex-font-lock-keywords-1 | 509 | (append tex-font-lock-keywords-1 |
| 505 | (eval-when-compile | 510 | (eval-when-compile |
| @@ -553,16 +558,19 @@ An alternative value is \" . \", if you use a font with a narrow period." | |||
| 553 | ;; | 558 | ;; |
| 554 | ;; Font environments. It seems a bit dubious to use `bold' etc. faces | 559 | ;; Font environments. It seems a bit dubious to use `bold' etc. faces |
| 555 | ;; since we might not be able to display those fonts. | 560 | ;; since we might not be able to display those fonts. |
| 556 | (list (concat slash bold " *" arg) 2 '(quote bold) 'append) | 561 | (list (concat slash bold " *" arg) 2 |
| 557 | (list (concat slash italic " *" arg) 2 '(quote italic) 'append) | 562 | '(tex-font-lock-append-prop 'bold) 'append) |
| 563 | (list (concat slash italic " *" arg) 2 | ||
| 564 | '(tex-font-lock-append-prop 'italic) 'append) | ||
| 558 | ;; (list (concat slash type arg) 2 '(quote bold-italic) 'append) | 565 | ;; (list (concat slash type arg) 2 '(quote bold-italic) 'append) |
| 559 | ;; | 566 | ;; |
| 560 | ;; Old-style bf/em/it/sl. Stop at `\\' and un-escaped `&', for tables. | 567 | ;; Old-style bf/em/it/sl. Stop at `\\' and un-escaped `&', for tables. |
| 561 | (list (concat "\\\\\\(em\\|it\\|sl\\)\\>" args) | 568 | (list (concat "\\\\\\(em\\|it\\|sl\\)\\>" args) |
| 562 | 2 '(quote italic) 'append) | 569 | 2 '(tex-font-lock-append-prop 'italic) 'append) |
| 563 | ;; This is separate from the previous one because of cases like | 570 | ;; This is separate from the previous one because of cases like |
| 564 | ;; {\em foo {\bf bar} bla} where both match. | 571 | ;; {\em foo {\bf bar} bla} where both match. |
| 565 | (list (concat "\\\\bf\\>" args) 1 '(quote bold) 'append))))) | 572 | (list (concat "\\\\\\(bf\\)\\>" args) |
| 573 | 2 '(tex-font-lock-append-prop 'bold) 'append))))) | ||
| 566 | "Gaudy expressions to highlight in TeX modes.") | 574 | "Gaudy expressions to highlight in TeX modes.") |
| 567 | 575 | ||
| 568 | (defun tex-font-lock-suscript (pos) | 576 | (defun tex-font-lock-suscript (pos) |
| @@ -604,11 +612,14 @@ An alternative value is \" . \", if you use a font with a narrow period." | |||
| 604 | (defvar tex-font-lock-syntactic-keywords | 612 | (defvar tex-font-lock-syntactic-keywords |
| 605 | (let ((verbs (regexp-opt tex-verbatim-environments t))) | 613 | (let ((verbs (regexp-opt tex-verbatim-environments t))) |
| 606 | `((,(concat "^\\\\begin *{" verbs "}.*\\(\n\\)") 2 "|") | 614 | `((,(concat "^\\\\begin *{" verbs "}.*\\(\n\\)") 2 "|") |
| 607 | (,(concat "^\\\\end *{" verbs "}\\(.?\\)") 2 | 615 | ;; Technically, we'd like to put the "|" property on the \n preceding |
| 608 | (unless (<= (match-beginning 0) (point-min)) | 616 | ;; the \end, but this would have 2 disadvantages: |
| 609 | (put-text-property (1- (match-beginning 0)) (match-beginning 0) | 617 | ;; 1 - it's wrong if the verbatim env is empty (the same \n is used to |
| 610 | 'syntax-table (string-to-syntax "|")) | 618 | ;; start and end the fenced-string). |
| 611 | "<")) | 619 | ;; 2 - font-lock considers the preceding \n as being part of the |
| 620 | ;; preceding line, so things gets screwed every time the previous | ||
| 621 | ;; line is re-font-locked on its own. | ||
| 622 | (,(concat "^\\(\\\\\\)end *{" verbs "}\\(.?\\)") (1 "|") (3 "<")) | ||
| 612 | ;; ("^\\(\\\\\\)begin *{comment}" 1 "< b") | 623 | ;; ("^\\(\\\\\\)begin *{comment}" 1 "< b") |
| 613 | ;; ("^\\\\end *{comment}.*\\(\n\\)" 1 "> b") | 624 | ;; ("^\\\\end *{comment}.*\\(\n\\)" 1 "> b") |
| 614 | ("\\\\verb\\**\\([^a-z@*]\\)" 1 "\"")))) | 625 | ("\\\\verb\\**\\([^a-z@*]\\)" 1 "\"")))) |