diff options
| author | Stefan Monnier | 2020-03-25 14:09:48 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2020-03-25 14:09:48 -0400 |
| commit | 11b37a4167d2eee4cb1f467a7f8ebaa6c8667ce9 (patch) | |
| tree | 21e986e66ba009cea27b8f6ad79c37a9dee08784 | |
| parent | 74489bdcb663722b1747f6a3f81f1f111c751f04 (diff) | |
| download | emacs-11b37a4167d2eee4cb1f467a7f8ebaa6c8667ce9.tar.gz emacs-11b37a4167d2eee4cb1f467a7f8ebaa6c8667ce9.zip | |
* 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.
| -rw-r--r-- | lisp/textmodes/conf-mode.el | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/lisp/textmodes/conf-mode.el b/lisp/textmodes/conf-mode.el index 79312757a2d..722fc0a3137 100644 --- a/lisp/textmodes/conf-mode.el +++ b/lisp/textmodes/conf-mode.el | |||
| @@ -405,27 +405,31 @@ See also `conf-space-mode', `conf-colon-mode', `conf-javaprop-mode', | |||
| 405 | 405 | ||
| 406 | \\{conf-mode-map}" | 406 | \\{conf-mode-map}" |
| 407 | 407 | ||
| 408 | ;; `conf-mode' plays two roles: it's the parent of several sub-modes | 408 | (setq-local font-lock-defaults '(conf-font-lock-keywords nil t nil nil)) |
| 409 | ;; but it's also the function that chooses between those submodes. | 409 | ;; Let newcomment.el decide this for itself. |
| 410 | ;; To tell the difference between those two cases where the function | 410 | ;; (setq-local comment-use-syntax t) |
| 411 | ;; might be called, we check `delay-mode-hooks'. | 411 | (setq-local parse-sexp-ignore-comments t) |
| 412 | ;; (adopted from tex-mode.el) | 412 | (setq-local outline-regexp "[ \t]*\\(?:\\[\\|.+[ \t\n]*{\\)") |
| 413 | (if (not delay-mode-hooks) | 413 | (setq-local outline-heading-end-regexp "[\n}]") |
| 414 | (funcall (conf--guess-mode)) | 414 | (setq-local outline-level #'conf-outline-level) |
| 415 | 415 | (setq-local imenu-generic-expression | |
| 416 | (setq-local font-lock-defaults '(conf-font-lock-keywords nil t nil nil)) | 416 | '(("Parameters" "^[ \t]*\\(.+?\\)[ \t]*=" 1) |
| 417 | ;; Let newcomment.el decide this for itself. | 417 | ;; [section] |
| 418 | ;; (setq-local comment-use-syntax t) | 418 | (nil "^[ \t]*\\[[ \t]*\\(.+\\)[ \t]*\\]" 1) |
| 419 | (setq-local parse-sexp-ignore-comments t) | 419 | ;; section { ... } |
| 420 | (setq-local outline-regexp "[ \t]*\\(?:\\[\\|.+[ \t\n]*{\\)") | 420 | (nil "^[ \t]*\\([^=:{} \t\n][^=:{}\n]+\\)[ \t\n]*{" 1)))) |
| 421 | (setq-local outline-heading-end-regexp "[\n}]") | 421 | |
| 422 | (setq-local outline-level #'conf-outline-level) | 422 | ;; `conf-mode' plays two roles: it's the parent of several sub-modes |
| 423 | (setq-local imenu-generic-expression | 423 | ;; but it's also the function that chooses between those submodes. |
| 424 | '(("Parameters" "^[ \t]*\\(.+?\\)[ \t]*=" 1) | 424 | ;; To tell the difference between those two cases where the function |
| 425 | ;; [section] | 425 | ;; might be called, we check `delay-mode-hooks'. |
| 426 | (nil "^[ \t]*\\[[ \t]*\\(.+\\)[ \t]*\\]" 1) | 426 | ;; (inspired from tex-mode.el) |
| 427 | ;; section { ... } | 427 | (advice-add 'conf-mode :around |
| 428 | (nil "^[ \t]*\\([^=:{} \t\n][^=:{}\n]+\\)[ \t\n]*{" 1))))) | 428 | (lambda (orig-fun) |
| 429 | "Redirect to one of the submodes when called directly." | ||
| 430 | (funcall (if delay-mode-hooks orig-fun (conf--guess-mode))))) | ||
| 431 | |||
| 432 | |||
| 429 | 433 | ||
| 430 | (defun conf-mode-initialize (comment &optional font-lock) | 434 | (defun conf-mode-initialize (comment &optional font-lock) |
| 431 | "Initializations for sub-modes of `conf-mode'. | 435 | "Initializations for sub-modes of `conf-mode'. |