branch: feature/fix-mode-names-overlap
commit 994079d8cddefbe6d641ab630213f442a66eaf74
Author: Ikumi Keita <ik...@ikumi.que.jp>
Commit: Ikumi Keita <ik...@ikumi.que.jp>

    Delete ConTeXt-xx-mode experimentally
    
    * context-en.el (ConTeXt-en-mode): Rename to ConTeXt--mode-en and
    stop being major mode.
    (context-en-mode): Delete alias.
    * context-nl.el (ConTeXt-nl-mode): Rename to ConTeXt--mode-nl and
    stop being major mode.
    (context-nl-mode): Delete alias.
    * context.el (ConTeXt-mode): Revert to a form similar to the one
    before introducing `define-derived-mode'.  Call ConTeXt--mode-xx
    instead of ConTeXt-xx-mode.
    (ConTeXt--auto-mode): Delete.
---
 context-en.el | 21 +++++----------------
 context-nl.el | 21 +++++----------------
 context.el    | 23 ++++-------------------
 3 files changed, 14 insertions(+), 51 deletions(-)

diff --git a/context-en.el b/context-en.el
index 26f84564..c63a4fd1 100644
--- a/context-en.el
+++ b/context-en.el
@@ -200,29 +200,18 @@ That is, besides the section(-block) commands.")
    '("sub" ConTeXt-arg-define-ref (TeX-arg-literal " "))
    '("sym" (TeX-arg-string "Symbol") (TeX-arg-literal " "))))
 
-;;;###autoload
-(define-derived-mode ConTeXt-en-mode ConTeXt-mode "ConTeXt-en"
-  "Major mode for editing files for ConTeXt using its english interface.
-
-Entering `ConTeXt-mode' calls the value of `text-mode-hook',
-then the value of `TeX-mode-hook', and then the value
-of `ConTeXt-mode-hook'.
-
-Don't use `ConTeXt-en-mode-hook' and `ConTeXt-en-mode-map', both
-specific to this mode.  They are ignored unless `ConTeXt-en-mode'
-is called directly."
-  :syntax-table nil
-  :abbrev-table nil
+(defun ConTeXt--mode-en ()
+  "Set up ConTeXt mode for editing files under english interface.
+Helper function of `ConTeXt-mode'.  Don't use."
 
   ;; set the ConTeXt interface
   (setq ConTeXt-current-interface "en")
 
   ;; initialization
   (ConTeXt-mode-common-initialization)
-  (ConTeXt-en-mode-initialization))
+  (ConTeXt-en-mode-initialization)
 
-;;;###autoload
-(defalias 'context-en-mode #'ConTeXt-en-mode)
+  (setq mode-name "ConTeXt-en"))
 
 (provide 'context-en)
 
diff --git a/context-nl.el b/context-nl.el
index dfbcc3ac..721b127f 100644
--- a/context-nl.el
+++ b/context-nl.el
@@ -178,29 +178,18 @@ That is, besides the section(-block) commands.")
    '("sub" ConTeXt-arg-define-ref (TeX-arg-literal " "))
    '("sym" (TeX-arg-string "Symbol") (TeX-arg-literal " "))))
 
-;;;###autoload
-(define-derived-mode ConTeXt-nl-mode ConTeXt-mode "ConTeXt-nl"
-  "Major mode for editing files for ConTeXt using its dutch interface.
-
-Entering `ConTeXt-mode' calls the value of `text-mode-hook',
-then the value of `TeX-mode-hook', and then the value
-of `ConTeXt-mode-hook'.
-
-Don't use `ConTeXt-nl-mode-hook' and `ConTeXt-nl-mode-map', both
-specific to this mode.  They are ignored unless `ConTeXt-nl-mode'
-is called directly."
-  :syntax-table nil
-  :abbrev-table nil
+(defun ConTeXt--mode-nl ()
+  "Set up ConTeXt mode for editing files under dutch interface.
+Helper function of `ConTeXt-mode'.  Don't use."
 
   ;; set the ConTeXt interface
   (setq ConTeXt-current-interface "nl")
 
   ;; initialization
   (ConTeXt-mode-common-initialization)
-  (ConTeXt-nl-mode-initialization))
+  (ConTeXt-nl-mode-initialization)
 
-;;;###autoload
-(defalias 'context-nl-mode #'ConTeXt-nl-mode)
+  (setq mode-name "ConTeXt-nl"))
 
 (provide 'context-nl)
 
diff --git a/context.el b/context.el
index 5774ac93..1c5ac8ef 100644
--- a/context.el
+++ b/context.el
@@ -1919,25 +1919,10 @@ that is, you do _not_ have to cater for this yourself 
by adding \\\\\\=' or $."
 Entering `ConTeXt-mode' calls the value of `text-mode-hook',
 then the value of `TeX-mode-hook', and then the value
 of `ConTeXt-mode-hook'."
-  ;; When called as parent of ConTeXt-{en,nl}-mode, do nothing to
-  ;; avoid `TeX-add-symbols' and `ConTeXt-add-environments' for wrong
-  ;; language interface.
-  (add-hook 'change-major-mode-after-body-hook #'ConTeXt--auto-mode nil t))
-
-(defun ConTeXt--auto-mode ()
-  ;; When called as not parent of ConTeXt-{en,nl}-mode, guess ConTeXt
-  ;; interface and use it.
-  (remove-hook 'change-major-mode-after-body-hook #'ConTeXt--auto-mode t)
-  (when (string-equal mode-name "ConTeXt")
-    (context-guess-current-interface)
-    (ConTeXt-mode-common-initialization)
-    (require (intern (concat "context-" ConTeXt-current-interface)))
-    ;; This bypasses call to ConTeXt-{en,nl}-mode.  Consequently,
-    ;; their mode-specific hook/keymap are ignored.
-    (funcall (intern (concat "ConTeXt-" ConTeXt-current-interface 
"-mode-initialization")))
-
-    (setq mode-name
-          (concat "ConTeXt-" ConTeXt-current-interface)))
+  (context-guess-current-interface)
+  (require (intern (concat "context-" ConTeXt-current-interface)))
+  (funcall (intern (concat "ConTeXt--mode-" ConTeXt-current-interface)))
+
   ;; set mode line
   (setq TeX-base-mode-name mode-name))
 

Reply via email to