aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/textmodes
diff options
context:
space:
mode:
authorStefan Monnier2007-07-16 18:38:05 +0000
committerStefan Monnier2007-07-16 18:38:05 +0000
commitc25d0edb6ec8b0381d330455520e1e4327bf2ed1 (patch)
treee86547cb3eab75a52de4aa41cca223b5fec0a0d8 /lisp/textmodes
parent1de49d4e219d9f817dc5bac5fbb8cd1a4197e02b (diff)
downloademacs-c25d0edb6ec8b0381d330455520e1e4327bf2ed1.tar.gz
emacs-c25d0edb6ec8b0381d330455520e1e4327bf2ed1.zip
(tex-verbatim-environments): Add safe-local-variable property.
(tex-font-lock-syntactic-keywords): Lookup tex-verbatim-environments when starting font-lock rather than when loading tex-mode.el.
Diffstat (limited to 'lisp/textmodes')
-rw-r--r--lisp/textmodes/tex-mode.el41
1 files changed, 23 insertions, 18 deletions
diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el
index 034caeee702..eb1429b41e5 100644
--- a/lisp/textmodes/tex-mode.el
+++ b/lisp/textmodes/tex-mode.el
@@ -637,26 +637,31 @@ An alternative value is \" . \", if you use a font with a narrow period."
637 637
638(defvar tex-verbatim-environments 638(defvar tex-verbatim-environments
639 '("verbatim" "verbatim*")) 639 '("verbatim" "verbatim*"))
640(put 'tex-verbatim-environments 'safe-local-variable
641 (lambda (x) (require 'cl) (every 'stringp x)))
640 642
641(defvar tex-font-lock-syntactic-keywords 643(defvar tex-font-lock-syntactic-keywords
642 (let ((verbs (regexp-opt tex-verbatim-environments t))) 644 '((eval . `(,(concat "^\\\\begin *{"
643 `((,(concat "^\\\\begin *{" verbs "}.*\\(\n\\)") 2 "|") 645 (regexp-opt tex-verbatim-environments t)
644 ;; Technically, we'd like to put the "|" property on the \n preceding 646 "}.*\\(\n\\)") 2 "|"))
645 ;; the \end, but this would have 2 disadvantages: 647 ;; Technically, we'd like to put the "|" property on the \n preceding
646 ;; 1 - it's wrong if the verbatim env is empty (the same \n is used to 648 ;; the \end, but this would have 2 disadvantages:
647 ;; start and end the fenced-string). 649 ;; 1 - it's wrong if the verbatim env is empty (the same \n is used to
648 ;; 2 - font-lock considers the preceding \n as being part of the 650 ;; start and end the fenced-string).
649 ;; preceding line, so things gets screwed every time the previous 651 ;; 2 - font-lock considers the preceding \n as being part of the
650 ;; line is re-font-locked on its own. 652 ;; preceding line, so things gets screwed every time the previous
651 ;; There's a hack in tex-font-lock-keywords-1 to remove the verbatim 653 ;; line is re-font-locked on its own.
652 ;; face from the \ but C-M-f still jumps to the wrong spot :-( --Stef 654 ;; There's a hack in tex-font-lock-keywords-1 to remove the verbatim
653 (,(concat "^\\(\\\\\\)end *{" verbs "}\\(.?\\)") (1 "|") (3 "<")) 655 ;; face from the \ but C-M-f still jumps to the wrong spot :-( --Stef
654 ;; ("^\\(\\\\\\)begin *{comment}" 1 "< b") 656 (eval . `(,(concat "^\\(\\\\\\)end *{"
655 ;; ("^\\\\end *{comment}.*\\(\n\\)" 1 "> b") 657 (regexp-opt tex-verbatim-environments t)
656 ("\\\\verb\\**\\([^a-z@*]\\)" 658 "}\\(.?\\)") (1 "|") (3 "<")))
657 ;; Do it last, because it uses syntax-ppss which needs the 659 ;; ("^\\(\\\\\\)begin *{comment}" 1 "< b")
658 ;; syntax-table properties of previous entries. 660 ;; ("^\\\\end *{comment}.*\\(\n\\)" 1 "> b")
659 1 (tex-font-lock-verb (match-end 1)))))) 661 ("\\\\verb\\**\\([^a-z@*]\\)"
662 ;; Do it last, because it uses syntax-ppss which needs the
663 ;; syntax-table properties of previous entries.
664 1 (tex-font-lock-verb (match-end 1)))))
660 665
661(defun tex-font-lock-unfontify-region (beg end) 666(defun tex-font-lock-unfontify-region (beg end)
662 (font-lock-default-unfontify-region beg end) 667 (font-lock-default-unfontify-region beg end)