Subject: bug#67463: 30.0.50; Eglot may manage js-json-mode buffers with wrong server

From: Stefan Monnier <[email-masked]>
Date: Sun, 07 Jan 2024 22:21:39 -0500

>> I suggest the patch below instead, which also "quick" but much less dirty.
> I didn't see it, did you attach it?

See second try below.

> Extra parents, muted parents, siblings become parents,
> definitely some good 90's sitcom material :-)

can't wait to see your script,

        Stefan
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index 0115feb0e97..f042774431d 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -3702,6 +3702,9 @@ js-base-mode
 (define-derived-mode js-mode js-base-mode "JavaScript"
   "Major mode for editing JavaScript."
   :group 'js
+  (js--mode-setup))
+
+(defun js--mode-setup ()
   ;; Ensure all CC Mode "lang variables" are set to valid values.
   (c-init-language-vars js-mode)
   (setq-local indent-line-function #'js-indent-line)
@@ -3924,7 +3927,8 @@ js-ts--syntax-propertize
         (put-text-property (1- ne) ne 'syntax-table syntax)))))
 
 ;;;###autoload
-(define-derived-mode js-json-mode js-mode "JSON"
+(define-derived-mode js-json-mode prog-mode "JSON"
+  (js--mode-setup) ;Reuse most of `js-mode', but not as parent (bug#67463).
   (setq-local js-enabled-frameworks nil)
   ;; Speed up `syntax-ppss': JSON files can be big but can't hold
   ;; regexp matchers nor #! thingies (and `js-enabled-frameworks' is nil).