Subject: Re: bug#74339: 30.0.92; CC Mode stomps C TS Mode

From: Stefan Monnier <[email-masked]>
Date: Thu, 14 Nov 2024 16:26:35 -0500

For reference, here's the patch I'm suggesting.

        Stefan

diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el
index 8ce4da56ef7..2e985ef9a83 100644
--- a/lisp/progmodes/cc-mode.el
+++ b/lisp/progmodes/cc-mode.el
@@ -3331,16 +3331,11 @@ c-submit-bug-report
 ;; Mode has been loaded, the symbols `c-mode' etc., will call CC Mode's
 ;; modes rather than c-ts-mode etc..
 (when (boundp 'major-mode-remap-defaults)
-  (add-to-list 'major-mode-remap-defaults '(c++-mode . c++-ts-mode))
-  (add-to-list 'major-mode-remap-defaults '(c-mode . c-ts-mode))
-  (add-to-list 'major-mode-remap-defaults '(c-or-c++-mode . c-or-c++-ts-mode))
   (let (entry)
     (dolist (mode '(c-mode c++-mode c-or-c++-mode))
-      (if (and (setq entry (assq mode major-mode-remap-defaults))
-	       (null (cdr entry)))
-	  (setq major-mode-remap-defaults
-		(delq entry major-mode-remap-defaults)))
-      (push (cons mode nil) major-mode-remap-defaults))))
+      (while (setq entry (assq mode major-mode-remap-defaults))
+	(setq major-mode-remap-defaults
+	      (delq entry major-mode-remap-defaults))))))
 
 
 (cc-provide 'cc-mode)