* bug#60643: 29.0.50; set-buffer-major-mode resets buffer local variables
@ 2023-01-08 4:48 Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-08 5:45 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-08 6:00 ` Eli Zaretskii
0 siblings, 2 replies; 5+ messages in thread
From: Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-01-08 4:48 UTC (permalink / raw)
To: 60643
Hello!
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?
Thank you!!
Joseph
In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.30, cairo version 1.16.0)
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Debian GNU/Linux 11 (bullseye)
Configured using:
'configure
CONFIG_SHELL=/gnu/store/4y5m9lb8k3qkb1y9m02sw9w9a6hacd16-bash-minimal-5.1.8/bin/bash
SHELL=/gnu/store/4y5m9lb8k3qkb1y9m02sw9w9a6hacd16-bash-minimal-5.1.8/bin/bash
--prefix=/gnu/store/4mnib031vflf88ms8w7kyfahcbv1k9vc-emacs-next-29.0.50-3.22e8a77
--enable-fast-install --with-modules --with-cairo
--with-native-compilation --disable-build-details'
Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES
NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3
THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#60643: 29.0.50; set-buffer-major-mode resets buffer local variables
2023-01-08 4:48 bug#60643: 29.0.50; set-buffer-major-mode resets buffer local variables Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-01-08 5:45 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-08 6:00 ` Eli Zaretskii
1 sibling, 0 replies; 5+ messages in thread
From: Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-01-08 5:45 UTC (permalink / raw)
To: Joseph Turner; +Cc: 60643
Joseph Turner via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org> writes:
> Hello!
>
> 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?
>
> Thank you!!
>
> Joseph
>
> In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
> 3.24.30, cairo version 1.16.0)
> Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
> System Description: Debian GNU/Linux 11 (bullseye)
>
> Configured using:
> 'configure
> CONFIG_SHELL=/gnu/store/4y5m9lb8k3qkb1y9m02sw9w9a6hacd16-bash-minimal-5.1.8/bin/bash
> SHELL=/gnu/store/4y5m9lb8k3qkb1y9m02sw9w9a6hacd16-bash-minimal-5.1.8/bin/bash
> --prefix=/gnu/store/4mnib031vflf88ms8w7kyfahcbv1k9vc-emacs-next-29.0.50-3.22e8a77
> --enable-fast-install --with-modules --with-cairo
> --with-native-compilation --disable-build-details'
>
> Configured features:
> ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
> JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES
> NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3
> THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB
There is another concept called "permanent local variables" which you
might be thinking about when looking at "local variables", see info node
`(elisp) Standard Properties' for more information.
Best,
RY
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#60643: 29.0.50; set-buffer-major-mode resets buffer local variables
2023-01-08 4:48 bug#60643: 29.0.50; set-buffer-major-mode resets buffer local variables Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-08 5:45 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-01-08 6:00 ` Eli Zaretskii
2023-01-08 9:09 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-08 9:09 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
1 sibling, 2 replies; 5+ messages in thread
From: Eli Zaretskii @ 2023-01-08 6:00 UTC (permalink / raw)
To: Joseph Turner; +Cc: 60643
> 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@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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#60643: 29.0.50; set-buffer-major-mode resets buffer local variables
2023-01-08 6:00 ` Eli Zaretskii
@ 2023-01-08 9:09 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-08 9:09 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
1 sibling, 0 replies; 5+ messages in thread
From: Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-01-08 9:09 UTC (permalink / raw)
To: Eli Zaretskii, ruijie; +Cc: 60643
Hello!
Eli Zaretskii <eliz@gnu.org> writes:
> 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.
Ruijie Yu <ruijie@netyu.xyz> writes:
> There is another concept called "permanent local variables" which you
> might be thinking about when looking at "local variables", see info node
> `(elisp) Standard Properties' for more information.
Thank you both for your help!! This solves it:
(put 'test-var 'permanent-local t)
Joseph
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#60643: 29.0.50; set-buffer-major-mode resets buffer local variables
2023-01-08 6:00 ` Eli Zaretskii
2023-01-08 9:09 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-01-08 9:09 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
1 sibling, 0 replies; 5+ messages in thread
From: Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-01-08 9:09 UTC (permalink / raw)
To: Eli Zaretskii, ruijie; +Cc: 60643-done
Hello!
Eli Zaretskii <eliz@gnu.org> writes:
> 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.
Ruijie Yu <ruijie@netyu.xyz> writes:
> There is another concept called "permanent local variables" which you
> might be thinking about when looking at "local variables", see info node
> `(elisp) Standard Properties' for more information.
Thank you both for your help!! This solves it:
(put 'test-var 'permanent-local t)
Joseph
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-01-08 9:09 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-08 4:48 bug#60643: 29.0.50; set-buffer-major-mode resets buffer local variables Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-08 5:45 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-08 6:00 ` Eli Zaretskii
2023-01-08 9:09 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-08 9:09 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).