changeset 81912:82e8a862c00b

(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.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Mon, 16 Jul 2007 18:38:05 +0000
parents 2d5f4f5607c1
children cecb560e9ace
files lisp/ChangeLog lisp/textmodes/tex-mode.el
diffstat 2 files changed, 28 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Mon Jul 16 16:59:58 2007 +0000
+++ b/lisp/ChangeLog	Mon Jul 16 18:38:05 2007 +0000
@@ -1,5 +1,10 @@
 2007-07-16  Stefan Monnier  <monnier@iro.umontreal.ca>
 
+	* textmodes/tex-mode.el (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.
+
 	* progmodes/sh-script.el (sh-font-lock-quoted-subshell): Skip over the
 	whole $( rather than just the $.  Rename from sh-quoted-subshell.
 	(sh-font-lock-syntactic-keywords): Adjust call accordingly.
--- a/lisp/textmodes/tex-mode.el	Mon Jul 16 16:59:58 2007 +0000
+++ b/lisp/textmodes/tex-mode.el	Mon Jul 16 18:38:05 2007 +0000
@@ -637,26 +637,31 @@
 
 (defvar tex-verbatim-environments
   '("verbatim" "verbatim*"))
+(put 'tex-verbatim-environments 'safe-local-variable
+     (lambda (x) (require 'cl) (every 'stringp x)))
 
 (defvar tex-font-lock-syntactic-keywords
-  (let ((verbs (regexp-opt tex-verbatim-environments t)))
-    `((,(concat "^\\\\begin *{" verbs "}.*\\(\n\\)") 2 "|")
-      ;; Technically, we'd like to put the "|" property on the \n preceding
-      ;; the \end, but this would have 2 disadvantages:
-      ;; 1 - it's wrong if the verbatim env is empty (the same \n is used to
-      ;;     start and end the fenced-string).
-      ;; 2 - font-lock considers the preceding \n as being part of the
-      ;;     preceding line, so things gets screwed every time the previous
-      ;;     line is re-font-locked on its own.
-      ;; There's a hack in tex-font-lock-keywords-1 to remove the verbatim
-      ;; face from the \ but C-M-f still jumps to the wrong spot :-(  --Stef
-      (,(concat "^\\(\\\\\\)end *{" verbs "}\\(.?\\)") (1 "|") (3 "<"))
-      ;; ("^\\(\\\\\\)begin *{comment}" 1 "< b")
-      ;; ("^\\\\end *{comment}.*\\(\n\\)" 1 "> b")
-      ("\\\\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))))))
+  '((eval . `(,(concat "^\\\\begin *{"
+                       (regexp-opt tex-verbatim-environments t)
+                       "}.*\\(\n\\)") 2 "|"))
+    ;; Technically, we'd like to put the "|" property on the \n preceding
+    ;; the \end, but this would have 2 disadvantages:
+    ;; 1 - it's wrong if the verbatim env is empty (the same \n is used to
+    ;;     start and end the fenced-string).
+    ;; 2 - font-lock considers the preceding \n as being part of the
+    ;;     preceding line, so things gets screwed every time the previous
+    ;;     line is re-font-locked on its own.
+    ;; There's a hack in tex-font-lock-keywords-1 to remove the verbatim
+    ;; face from the \ but C-M-f still jumps to the wrong spot :-(  --Stef
+    (eval . `(,(concat "^\\(\\\\\\)end *{"
+                       (regexp-opt tex-verbatim-environments t)
+                       "}\\(.?\\)") (1 "|") (3 "<")))
+    ;; ("^\\(\\\\\\)begin *{comment}" 1 "< b")
+    ;; ("^\\\\end *{comment}.*\\(\n\\)" 1 "> b")
+    ("\\\\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)