1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-20 18:17:20 +00:00

* lisp/textmodes/conf-mode.el (conf-mode): Fix last change

`delay-mode-hooks` cannot be tested from within `define-derived-mode`
because it's always non-nil in there, so arrange to test it before we
enter the body.
This commit is contained in:
Stefan Monnier 2020-03-25 14:09:48 -04:00
parent 74489bdcb6
commit 11b37a4167

View File

@ -405,27 +405,31 @@ See also `conf-space-mode', `conf-colon-mode', `conf-javaprop-mode',
\\{conf-mode-map}"
;; `conf-mode' plays two roles: it's the parent of several sub-modes
;; but it's also the function that chooses between those submodes.
;; To tell the difference between those two cases where the function
;; might be called, we check `delay-mode-hooks'.
;; (adopted from tex-mode.el)
(if (not delay-mode-hooks)
(funcall (conf--guess-mode))
(setq-local font-lock-defaults '(conf-font-lock-keywords nil t nil nil))
;; Let newcomment.el decide this for itself.
;; (setq-local comment-use-syntax t)
(setq-local parse-sexp-ignore-comments t)
(setq-local outline-regexp "[ \t]*\\(?:\\[\\|.+[ \t\n]*{\\)")
(setq-local outline-heading-end-regexp "[\n}]")
(setq-local outline-level #'conf-outline-level)
(setq-local imenu-generic-expression
'(("Parameters" "^[ \t]*\\(.+?\\)[ \t]*=" 1)
;; [section]
(nil "^[ \t]*\\[[ \t]*\\(.+\\)[ \t]*\\]" 1)
;; section { ... }
(nil "^[ \t]*\\([^=:{} \t\n][^=:{}\n]+\\)[ \t\n]*{" 1))))
;; `conf-mode' plays two roles: it's the parent of several sub-modes
;; but it's also the function that chooses between those submodes.
;; To tell the difference between those two cases where the function
;; might be called, we check `delay-mode-hooks'.
;; (inspired from tex-mode.el)
(advice-add 'conf-mode :around
(lambda (orig-fun)
"Redirect to one of the submodes when called directly."
(funcall (if delay-mode-hooks orig-fun (conf--guess-mode)))))
(setq-local font-lock-defaults '(conf-font-lock-keywords nil t nil nil))
;; Let newcomment.el decide this for itself.
;; (setq-local comment-use-syntax t)
(setq-local parse-sexp-ignore-comments t)
(setq-local outline-regexp "[ \t]*\\(?:\\[\\|.+[ \t\n]*{\\)")
(setq-local outline-heading-end-regexp "[\n}]")
(setq-local outline-level #'conf-outline-level)
(setq-local imenu-generic-expression
'(("Parameters" "^[ \t]*\\(.+?\\)[ \t]*=" 1)
;; [section]
(nil "^[ \t]*\\[[ \t]*\\(.+\\)[ \t]*\\]" 1)
;; section { ... }
(nil "^[ \t]*\\([^=:{} \t\n][^=:{}\n]+\\)[ \t\n]*{" 1)))))
(defun conf-mode-initialize (comment &optional font-lock)
"Initializations for sub-modes of `conf-mode'.