emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 11b37a4: * lisp/textmodes/conf-mode.el (conf-mode): Fix last chan


From: Stefan Monnier
Subject: master 11b37a4: * lisp/textmodes/conf-mode.el (conf-mode): Fix last change
Date: Wed, 25 Mar 2020 14:09:52 -0400 (EDT)

branch: master
commit 11b37a4167d2eee4cb1f467a7f8ebaa6c8667ce9
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>

    * 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.
---
 lisp/textmodes/conf-mode.el | 46 ++++++++++++++++++++++++---------------------
 1 file changed, 25 insertions(+), 21 deletions(-)

diff --git a/lisp/textmodes/conf-mode.el b/lisp/textmodes/conf-mode.el
index 7931275..722fc0a 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',
 
 \\{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)))))
+  (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)))))
+
+
 
 (defun conf-mode-initialize (comment &optional font-lock)
   "Initializations for sub-modes of `conf-mode'.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]