branch: scratch/editorconfig-cc
commit df95ca5e4fa606aa00ec083b9f9807b45968de2d
Author: 10sr <8.slas...@gmail.com>
Commit: Stefan Monnier <monn...@iro.umontreal.ca>

    Do not call mode func when current mode is a child mode of target (#179)
---
 editorconfig.el | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/editorconfig.el b/editorconfig.el
index ec0a78efac..b8bc2c09bb 100644
--- a/editorconfig.el
+++ b/editorconfig.el
@@ -323,11 +323,9 @@ FILETYPE should be s string like `\"ini\"`, if not nil or 
empty string."
                                  ""))
                    (intern (concat filetype
                                    "-mode")))))
-    (when (and mode
-               (not (editorconfig--is-a-mode-p major-mode
-                                               mode)))
+    (when mode
       (if (fboundp mode)
-          (funcall mode)
+          (editorconig-apply-major-mode-safely mode)
         (display-warning :error (format "Major-mode `%S' not found"
                                         mode))
         nil))))
@@ -349,10 +347,13 @@ This funcion will avoid such cases and set `major-mode' 
safely.
 Just checking current `major-mode' value is not enough, because it can be
 different from MODE value (for example, `conf-mode' will set `major-mode' to
 `conf-unix-mode' or another conf mode)."
+  (cl-assert mode)
   (when (and (not (eq mode
                       editorconfig--apply-major-mode-currently))
              (not (eq mode
-                      major-mode)))
+                      major-mode))
+             (not (editorconfig--is-a-mode-p major-mode
+                                             mode)))
     (unwind-protect
         (progn
           (setq editorconfig--apply-major-mode-currently

Reply via email to