[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: setting non-user variables
From: |
Héctor Lahoz |
Subject: |
Re: setting non-user variables |
Date: |
Thu, 1 Jun 2017 17:22:10 +0200 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
Drew Adams wrote:
> > > (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 "...")
>
> Yes, `set-variable' is for "user variables", aka user options,
> only, aka symbols that satisfy predicate `user-variable-p'.
>
> Today, that means a variable that is defined using defcustom,
> or an alias to such a variable.
>
> It USED to also mean any variable whose doc string begins with `*'.
> Alas (IMHO), this feature was removed from Emacs 23 (i.e., long ago).
>
> In Emacs 22 and prior you could do this:
>
> (defvar foo 42 "*This is foo.")
> (put 'foo 'variable-interactive "nWidth: ")
>
> M-x set-variable foo RET
>
> Width: 13 RET
>
> And `foo' was available for completion (e.g. `f TAB') using
> `set-variable'.
>
> Giving a variable a `variable-interactive' property tells
> `set-variable' how to read a value for it.
>
You hit the nail on the head. In fact there is a "*" at the
beginning of the docstring and I was wondering why I put it
there some years ago.
Thanks a lot.