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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 60643 in the body.
You can then email your comments to 60643 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#60643; Package emacs. (Sun, 08 Jan 2023 04:58:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Joseph Turner <joseph <at> breatheoutbreathe.in>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 08 Jan 2023 04:58:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Joseph Turner <joseph <at> breatheoutbreathe.in>
To: bug-gnu-emacs <at> gnu.org
Subject: 29.0.50; set-buffer-major-mode resets buffer local variables
Date: Sat, 07 Jan 2023 20:48:54 -0800
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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60643; Package emacs. (Sun, 08 Jan 2023 05:51:02 GMT) Full text and rfc822 format available.

Message #8 received at 60643 <at> debbugs.gnu.org (full text, mbox):

From: Ruijie Yu <ruijie <at> netyu.xyz>
To: Joseph Turner <joseph <at> breatheoutbreathe.in>
Cc: 60643 <at> debbugs.gnu.org
Subject: Re: bug#60643: 29.0.50; set-buffer-major-mode resets buffer local
 variables
Date: Sat, 07 Jan 2023 23:45:52 -0600
Joseph Turner via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs <at> 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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60643; Package emacs. (Sun, 08 Jan 2023 06:00:02 GMT) Full text and rfc822 format available.

Message #11 received at 60643 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Joseph Turner <joseph <at> breatheoutbreathe.in>
Cc: 60643 <at> debbugs.gnu.org
Subject: Re: 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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60643; Package emacs. (Sun, 08 Jan 2023 10:28:02 GMT) Full text and rfc822 format available.

Message #14 received at 60643 <at> debbugs.gnu.org (full text, mbox):

From: Joseph Turner <joseph <at> breatheoutbreathe.in>
To: Eli Zaretskii <eliz <at> gnu.org>, ruijie <at> netyu.xyz
Cc: 60643 <at> debbugs.gnu.org
Subject: Re: bug#60643: 29.0.50; set-buffer-major-mode resets buffer local
 variables
Date: Sun, 08 Jan 2023 01:09:55 -0800
Hello!

Eli Zaretskii <eliz <at> 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 <at> 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




Reply sent to Joseph Turner <joseph <at> breatheoutbreathe.in>:
You have taken responsibility. (Sun, 08 Jan 2023 10:29:02 GMT) Full text and rfc822 format available.

Notification sent to Joseph Turner <joseph <at> breatheoutbreathe.in>:
bug acknowledged by developer. (Sun, 08 Jan 2023 10:29:02 GMT) Full text and rfc822 format available.

Message #19 received at 60643-done <at> debbugs.gnu.org (full text, mbox):

From: Joseph Turner <joseph <at> breatheoutbreathe.in>
To: Eli Zaretskii <eliz <at> gnu.org>, ruijie <at> netyu.xyz
Cc: 60643-done <at> debbugs.gnu.org
Subject: Re: bug#60643: 29.0.50; set-buffer-major-mode resets buffer local
 variables
Date: Sun, 08 Jan 2023 01:09:55 -0800
Hello!

Eli Zaretskii <eliz <at> 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 <at> 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




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 05 Feb 2023 12:24:05 GMT) Full text and rfc822 format available.

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.