GNU bug report logs - #60643
29.0.50; set-buffer-major-mode resets buffer local variables

Previous Next

Package: emacs;

Reported by: Joseph Turner <joseph <at> breatheoutbreathe.in>

Date: Sun, 8 Jan 2023 04:58:01 UTC

Severity: normal

Found in version 29.0.50

Done: Joseph Turner <joseph <at> breatheoutbreathe.in>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Eli Zaretskii <eliz <at> gnu.org>
To: Joseph Turner <joseph <at> breatheoutbreathe.in>
Cc: 60643 <at> debbugs.gnu.org
Subject: bug#60643: 29.0.50; set-buffer-major-mode resets buffer local variables
Date: Sun, 08 Jan 2023 08:00:11 +0200
> Date: Sat, 07 Jan 2023 20:48:54 -0800
> From:  Joseph Turner via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> 
> It appears that set-buffer-major-mode resets buffer local variables.
> 
> To reproduce with `emacs -Q`:
> 
> (defvar-local test-var nil)
> (setq test-var t)
> (message "%s" test-var) ;; t
> ;; (set-auto-mode)
> (set-buffer-major-mode (current-buffer))
> (message "%s" test-var) ;; nil
> 
> Is this behavior expected?

Yes, I think so.  Changing the major mode kills all buffer-local
variables.  If you don't want some variable to be killed, give it the
permanent-local property.




This bug report was last modified 2 years and 135 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.