all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#74339: 30.0.92; CC Mode stomps C TS Mode
@ 2024-11-13 14:00 Eli Zaretskii
  2024-11-13 15:13 ` Eli Zaretskii
                   ` (2 more replies)
  0 siblings, 3 replies; 86+ messages in thread
From: Eli Zaretskii @ 2024-11-13 14:00 UTC (permalink / raw)
  To: 74339; +Cc: Alan Mackenzie

To reproduce:

  emacs -Q
  M-x load-library RET c-ts-mode RET
  C-x C-f src/buffer.c
  M-: major-mode RET
   => c-ts-mode

So far, so good: the user loads c-ts-mode, which means she prefers
C/C++ TS Mode for C and C++ files, so visiting a C file turns on
c-ts-mode instead of the default CC Mode.

But:

  emacs -Q
  C-x C-f src/dispnew.c RET
  M-x load-library RET c-ts-mode RET
  C-x C-f src/buffer.c
  M-: major-mode RET
   => c-mode

This is unexpected.  It means that if even a single file loads CC
Mode, the user's preference of using C TS Mode is effectively ignored.

This seems to happen due to this code in cc-mode.el:

  ;; Make entries in `major-mode-remap-defaults' to ensure that when CC
  ;; 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))))

Here's what major-mode-remap-defaults looks like when I load c-ts-mode
into "emacs -Q":

  ((c-or-c++-mode . c-or-c++-ts-mode) (c-mode . c-ts-mode) (c++-mode . c++-ts-mode) (LaTeX-mode . latex-mode) (plain-TeX-mode . plain-tex-mode) (TeX-mode . tex-mode))

And here's how it looks if I first visit a C file (which loads
cc-mode):

  ((c-or-c++-mode) (c++-mode) (c-mode) (c-or-c++-mode . c-or-c++-ts-mode) (c-mode . c-ts-mode) (c++-mode . c++-ts-mode) (LaTeX-mode . latex-mode) (plain-TeX-mode . plain-tex-mode) (TeX-mode . tex-mode))

The above snippet from cc-mode.el was installed this last May, with
the following log message:

    In normal-mode, make c-mode call c-mode when CC Mode is loaded

    As regards which mode normal-mode calls for the symbols c-mode,
    etc., the first of the following which applies holds:
    (i) If the user has made a pertinent entry in
    major-mode-remap-alist, this is used.
    (ii) If CC Mode has been loaded, c-mode is called.
    (iii) If library c-ts-mode has been loaded, c-ts-mode is
    called.
    (iv) Otherwise c-mode is called.

    * lisp/progmodes/cc-mode.el (top level): Add entries to
    major-mode-remap-defaults to implement the above.

I don't quite understand the rationale (and even less the
implementation), and don't recall any discussions of this; there's
also no bug number for it.  But clearly the result is not acceptable,
and I very much hope that there's some simple bug here that can be
fixed real soon.  If the above is not a bug, but the intended (by you,
Alan) behavior, then we need to talk about changing it, because this
is not how user preferences in this regard are supposed to be heeded
by Emacs.

The expected behavior is: as soon as the user loads c-ts-mode, all the
subsequent C/C++ files are visited using C/C++ TS Mode.  To revert
back to CC Mode, the user must load cc-mode again.

In GNU Emacs 30.0.92 (build 21, i686-pc-mingw32) of 2024-11-11 built on
 ELIZ-PC
Windowing system distributor 'Microsoft Corp.', version 10.0.22631
System Description: Microsoft Windows 10 Enterprise (v10.0.2009.22631.4460)

Configured using:
 'configure -C --prefix=/d/usr --with-wide-int
 --enable-checking=yes,glyphs --without-native-compilation 'CFLAGS=-O0
 -gdwarf-4 -g3''

Configured features:
ACL GIF GMP GNUTLS HARFBUZZ JPEG LCMS2 LIBXML2 MODULES NOTIFY W32NOTIFY
PDUMPER PNG RSVG SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS
TREE_SITTER WEBP XPM ZLIB

Important settings:
  value of $LANG: ENU
  locale-coding-system: cp1252

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  minibuffer-regexp-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message mailcap yank-media puny dired
dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068
epg-config gnus-util text-property-search time-date subr-x mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
c++-ts-mode c-ts-mode c-ts-common treesit cl-loaddefs cl-lib thingatpt
find-func rmc iso-transl tooltip cconv eldoc paren electric uniquify
ediff-hook vc-hooks lisp-float-type elisp-mode mwheel touch-screen
dos-w32 ls-lisp disp-table term/w32-win w32-win w32-vars term/common-win
tool-bar dnd fontset image regexp-opt fringe tabulated-list replace
newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar
rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock
font-lock syntax font-core term/tty-colors frame minibuffer nadvice seq
simple cl-generic indonesian philippine cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite emoji-zwj charscript charprop case-table
epa-hook jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button
loaddefs theme-loaddefs faces cus-face macroexp files window
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget keymap hashtable-print-readable backquote threads
w32notify w32 lcms2 multi-tty move-toolbar make-network-process emacs)

Memory information:
((conses 16 49304 16294) (symbols 48 6997 0) (strings 16 17805 2859)
 (string-bytes 1 375146) (vectors 16 10077)
 (vector-slots 8 114927 6271) (floats 8 25 6) (intervals 40 301 140)
 (buffers 896 10))





^ permalink raw reply	[flat|nested] 86+ messages in thread

end of thread, other threads:[~2024-11-28 14:56 UTC | newest]

Thread overview: 86+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-13 14:00 bug#74339: 30.0.92; CC Mode stomps C TS Mode Eli Zaretskii
2024-11-13 15:13 ` Eli Zaretskii
2024-11-13 18:58 ` Alan Mackenzie
2024-11-13 20:13   ` Eli Zaretskii
2024-11-13 22:34     ` Alan Mackenzie
2024-11-13 22:57       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-14  6:59       ` Eli Zaretskii
2024-11-14  9:24         ` Dmitry Gutov
2024-11-14 10:05           ` Eli Zaretskii
2024-11-16 20:54             ` Andrea Corallo
2024-11-14 15:51           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-14 16:29             ` Dmitry Gutov
2024-11-14 16:49             ` Eli Zaretskii
2024-11-14 17:16               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-14 19:10                 ` Eli Zaretskii
2024-11-14 19:45                   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-14 16:20         ` Alan Mackenzie
2024-11-14 16:59           ` Eli Zaretskii
2024-11-14 17:45             ` Alan Mackenzie
2024-11-14 17:52               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-14 19:23               ` Eli Zaretskii
2024-11-14 19:53                 ` Alan Mackenzie
2024-11-14 20:21                   ` Eli Zaretskii
2024-11-14 20:38                     ` Alan Mackenzie
2024-11-14 21:06                       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-14 21:26                         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-15  8:17                           ` Eli Zaretskii
2024-11-15 16:17                             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-15  8:13                         ` Eli Zaretskii
2024-11-15  7:33                       ` Eli Zaretskii
2024-11-15 13:04                         ` Alan Mackenzie
2024-11-15 14:43                           ` Eli Zaretskii
2024-11-15 17:58                             ` Alan Mackenzie
2024-11-15 19:01                               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-15 19:46                                 ` Alan Mackenzie
2024-11-15 20:45                                   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-16 10:25                                     ` Eli Zaretskii
2024-11-16 14:03                                       ` Stefan Kangas
2024-11-16 14:35                                         ` Eli Zaretskii
2024-11-15 20:58                                   ` Stefan Kangas
2024-11-15 21:56                                     ` Alan Mackenzie
2024-11-16  3:22                                       ` Stefan Kangas
2024-11-16 11:45                                         ` Eli Zaretskii
2024-11-16 18:17                                         ` Alan Mackenzie
2024-11-16  6:17                                       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-16  8:18                                         ` Eli Zaretskii
     [not found]                                           ` <Zzi86KPmTv1Qb3nw@MAC.fritz.box>
     [not found]                                             ` <86ttc7f7jo.fsf@gnu.org>
2024-11-16 21:56                                               ` Alan Mackenzie
2024-11-17  6:31                                                 ` Eli Zaretskii
2024-11-16  9:52                                   ` Eli Zaretskii
2024-11-15 18:57                           ` Dmitry Gutov
2024-11-21  7:57                 ` Eli Zaretskii
2024-11-21 13:57                   ` Alan Mackenzie
2024-11-21 19:02                   ` Dmitry Gutov
2024-11-21 19:48                     ` Eli Zaretskii
2024-11-23 19:40                       ` Eli Zaretskii
2024-11-24  2:56                         ` Dmitry Gutov
2024-11-24  5:27                           ` Eli Zaretskii
2024-11-25  1:16                             ` Dmitry Gutov
2024-11-25 12:11                               ` Eli Zaretskii
2024-11-25 23:40                                 ` Dmitry Gutov
2024-11-26 14:26                                   ` Eli Zaretskii
2024-11-26 22:06                                     ` Dmitry Gutov
2024-11-27  3:28                                       ` Eli Zaretskii
2024-11-27 12:34                                         ` Dmitry Gutov
2024-11-28 14:56                                           ` Eli Zaretskii
2024-11-24 15:37                         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-24 16:01                           ` Christopher Dimech via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-24 16:30                             ` Eli Zaretskii
2024-11-24 16:27                           ` Eli Zaretskii
2024-11-24 16:47                             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-25  0:57                               ` Dmitry Gutov
2024-11-24  4:35                   ` Richard Stallman
2024-11-24  7:41                     ` Eli Zaretskii
2024-11-14 17:29           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-14 19:20             ` Eli Zaretskii
2024-11-14 19:38               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-14 20:37                 ` Eli Zaretskii
2024-11-14 20:58                   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-14 22:06                     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-15 12:02                       ` Eli Zaretskii
2024-11-15  7:58                     ` Eli Zaretskii
2024-11-15 16:12                       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-16 20:51       ` Andrea Corallo
2024-11-13 20:28 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-13 20:42   ` Eli Zaretskii
2024-11-13 20:46     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.