help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: setting non-user variables


From: tomas
Subject: Re: setting non-user variables
Date: Thu, 1 Jun 2017 12:02:09 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thu, Jun 01, 2017 at 11:24:03AM +0200, Héctor Lahoz wrote:
> Eli Zaretskii wrote:
> > > From: "Héctor Lahoz" <hectorlahoz@gmail.com>
> > > Date: Wed, 31 May 2017 16:26:44 +0200
> > > 
> > > Recently I upgraded my Emacs to version 24 (I don't like to live on
> > > the edge :-) and noticed that I can't use set-variable to set
> > > this buffer-local variable anymore. What should I do?
> > > Why was this changed?
> > > 
> > > ;; before I did:
> > > ;; set-variable RET mpkg-master-file RET "file.txt" RET
> > > (make-variable-buffer-local
> > >  (defvar mpkg-master-file))
> > 
> > What package defines mpkg-master-file?  I couldn't find it in packages
> > bundled with Emacs.
> 
> It is my own. Not published yet.
>  
> > Also, what version of Emacs did you have before the upgrade?
> 
> 23.4.1
> 
> So, to be clear. The variable is defined like this:
> 
> (make-variable-buffer-local
>  (defvar mpkg-master-file nil
>          "The path of the video associated to the current buffer"))
> 
> With 23 I could set the variable interactively, with 24 I can't.

I can confirm that (Emacs 26.0.50 here). Variables defined through
defvar seem not to be indexed, whether buffer local or not. If you
use `defcustom', though, this will work:

  (defcustom mpkg-master-file nil "...")

No idea how that interacts with buffer-local though.

To me, it looks intentional. I'm a bit pressed now (should be doing
other things), but I'd expect it to be somewhere in the NEWS.

The nice thing about defcustom is that you get lots of options, like
for setting an edit widget for the value (and possibly some validation
code). The ugly thing is that you now get to read some docs ;-)

Cheers
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlkv5iEACgkQBcgs9XrR2kZxUwCfZC0QPCcH04zPQsXbftnymFEl
i60AmwXmoIcFaVuMBi2SC1Djrd/wIpoS
=gAg3
-----END PGP SIGNATURE-----



reply via email to

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