changeset 72769:00b6d782491f

(conf-space-mode-internal): New subroutine. Reinit Font Lock mode. (conf-space-mode): Always make conf-space-keywords and conf-space-keywords-override local. Call conf-space-mode-internal directly as well as via hook.
author Richard M. Stallman <rms@gnu.org>
date Sun, 10 Sep 2006 00:30:46 +0000
parents db9ab4e6163c
children 3350729e576f
files lisp/textmodes/conf-mode.el
diffstat 1 files changed, 34 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/textmodes/conf-mode.el	Sun Sep 10 00:26:17 2006 +0000
+++ b/lisp/textmodes/conf-mode.el	Sun Sep 10 00:30:46 2006 +0000
@@ -470,15 +470,19 @@
   (conf-mode-initialize "#" 'conf-space-font-lock-keywords)
   (make-local-variable 'conf-assignment-sign)
   (setq conf-assignment-sign nil)
+  (make-local-variable 'conf-space-keywords)
+  (make-local-variable 'conf-space-keywords-override)
+  (setq conf-space-keywords-override nil)
   (cond (current-prefix-arg
-	 (make-local-variable 'conf-space-keywords-override)
 	 ;; By setting conf-space-keywords-override
-	 ;; we arrange for the hook function below
+	 ;; we arrange for conf-space-mode-internal
 	 ;; to override any value of conf-space-keywords
 	 ;; specified in a local variables list.
          (setq conf-space-keywords-override
 	       (if (> (prefix-numeric-value current-prefix-arg) 0)
 		   (read-string "Regexp to match keywords: "))))
+	;; If this is already set, don't replace it with the default.
+	(conf-space-keywords)
         (buffer-file-name
 	 ;; By setting conf-space-keywords directly, 
 	 ;; we let a value in the local variables list take precedence.
@@ -486,27 +490,36 @@
          (setq conf-space-keywords
 	       (assoc-default buffer-file-name conf-space-keywords-alist
 			      'string-match))))
-  ;; This is stuff to be done after parsing the local variables, once
-  ;; any local variable spec fo rconf-space-keywords is already in  effect.
-  (push (lambda ()
-	  (when conf-space-keywords-override
-	    (setq conf-space-keywords
-		  conf-space-keywords-override))
-	  (make-local-variable 'conf-assignment-regexp)
-	  (setq conf-assignment-regexp
-		(if conf-space-keywords
-		    (concat "\\(?:" conf-space-keywords "\\)[ \t]+.+?\\([ \t]+\\|$\\)")
-		  ".+?\\([ \t]+\\|$\\)"))
-	  (setq imenu-generic-expression
-		`(,@(cdr imenu-generic-expression)
-		  ("Parameters"
-		   ,(if conf-space-keywords
-			(concat "^[ \t]*\\(?:" conf-space-keywords
-				"\\)[ \t]+\\([^ \t\n]+\\)\\(?:[ \t]\\|$\\)")
-		      "^[ \t]*\\([^ \t\n[]+\\)\\(?:[ \t]\\|$\\)")
-		   1))))
+  (conf-space-mode-internal)
+  ;; In case the local variables list specifies conf-space-keywords,
+  ;; recompute other things from that afterward.
+  (push 'conf-space-mode-internal
 	hack-local-variables-hook))
 
+(defun conf-space-mode-internal ()
+  (when conf-space-keywords-override
+    (setq conf-space-keywords
+	  conf-space-keywords-override))
+  (make-local-variable 'conf-assignment-regexp)
+  (setq conf-assignment-regexp
+	(if conf-space-keywords
+	    (concat "\\(?:" conf-space-keywords "\\)[ \t]+.+?\\([ \t]+\\|$\\)")
+	  ".+?\\([ \t]+\\|$\\)"))
+  ;; If Font Lock is already enabled, reenable it with new
+  ;; conf-assignment-regexp.
+  (when (and font-lock-mode
+	     (boundp 'font-lock-keywords)) ;see `normal-mode'
+    (font-lock-add-keywords nil nil)
+    (font-lock-mode 1))
+  (setq imenu-generic-expression
+	`(,@(cdr imenu-generic-expression)
+	  ("Parameters"
+	   ,(if conf-space-keywords
+		(concat "^[ \t]*\\(?:" conf-space-keywords
+			"\\)[ \t]+\\([^ \t\n]+\\)\\(?:[ \t]\\|$\\)")
+	      "^[ \t]*\\([^ \t\n[]+\\)\\(?:[ \t]\\|$\\)")
+	   1))))
+
 ;;;###autoload
 (define-derived-mode conf-colon-mode conf-unix-mode "Conf[Colon]"
   "Conf Mode starter for Colon files.