1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-05 11:45:45 +00:00

(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.
This commit is contained in:
Richard M. Stallman 2006-09-10 00:30:52 +00:00
parent f90660aa86
commit dd3a63bf1a
2 changed files with 38 additions and 21 deletions

View File

@ -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 <slawomir.nowaczyk.847@student.lu.se> (tiny change)

View File

@ -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.