From dd3a63bf1a7b799d25c932fbb6a1bbced7470eee Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Sun, 10 Sep 2006 00:30:52 +0000 Subject: [PATCH] (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. --- lisp/ChangeLog | 4 +++ lisp/textmodes/conf-mode.el | 55 +++++++++++++++++++++++-------------- 2 files changed, 38 insertions(+), 21 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5f94fa6f83a..c9aa615145e 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -3,6 +3,10 @@ * textmodes/conf-mode.el (conf-space-mode): Use hack-local-variables-hook instead of calling hack-local-variables. (conf-space-keywords-override): New variable. + (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. 2006-09-09 Slawomir Nowaczyk (tiny change) diff --git a/lisp/textmodes/conf-mode.el b/lisp/textmodes/conf-mode.el index a44eeefa56a..a3471f16480 100644 --- a/lisp/textmodes/conf-mode.el +++ b/lisp/textmodes/conf-mode.el @@ -470,15 +470,19 @@ add /dev/mixer desktop" (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 @@ add /dev/mixer desktop" (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. -- 2.39.2