emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Subversion of user chosen major mode by Emacs.


From: Alan Mackenzie
Subject: Re: Subversion of user chosen major mode by Emacs.
Date: Wed, 29 May 2024 13:29:34 +0000

Hello, Eli.

On Wed, May 29, 2024 at 15:41:45 +0300, Eli Zaretskii wrote:
> > Date: Wed, 29 May 2024 11:16:44 +0000
> > Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org
> > From: Alan Mackenzie <acm@muc.de>

> > As I said, when I did M-x revert-buffer yesterday, Emacs changed my
> > major mode from C Mode to c-ts-mode.  This is clearly unacceptable.

> Please show a minimal recipe, starting from "emacs -Q", where
> reverting a buffer changes from c-mode to c-ts-mode.

With a recent master emacs:
(i) emacs -Q
(ii) Insert the following into *scratch* and evaluate it:

(defun c-make-ts-undefault-mode ()
  "Make the older C and C++ Modes the default major modes for C(++)
files."
  (interactive)
  (let (c)
    (dolist (l '(c-ts-mode c++-ts-mode c-or-c++-ts-mode))
      (while (setq c (rassq l auto-mode-alist))
        (setq auto-mode-alist (remq c auto-mode-alist))))))
(eval-after-load 'c-ts-mode '(c-make-ts-undefault-mode))

(load-library "cc-mode")

..

(iii) C-x C-f src/xdisp.c.  This is loaded with C Mode.
(iv) M-: (load-library "c-ts-mode").
(v) M-x revert-buffer.  Emacs reloads the buffer in c-ts-mode.

> As a general rule, revert-buffer does not guarantee the major mode
> will remain the same, not by default.  It calls normal-mode, so if
> anything has changed in automatic determination of the mode, you will
> get a different mode.  This is by design.

Such changes to the automatic determination should be as a result of
user choices.  There shouldn't be nasty surprises in store.

-- 
Alan Mackenzie (Nuremberg, Germany).



reply via email to

[Prev in Thread] Current Thread [Next in Thread]