* Documentation not clear for the Lisp function set-variable
@ 2005-06-19 11:14 Yoni Rabkin
2005-06-20 3:50 ` Richard Stallman
0 siblings, 1 reply; 47+ messages in thread
From: Yoni Rabkin @ 2005-06-19 11:14 UTC (permalink / raw
Hello, I'm on CVS GNU Emacs 22.0.50.1
As far as I understand, the function set-variable, called
interactively will only tab-complete the names of variables defined as
"interactive".
This fact is not stated in the documentation string for set-variable.
This is only mentioned (or could be understood) from the documentation
itself. The documentation string reads as follows:
"Set VARIABLE to VALUE. VALUE is a Lisp object.
When using this interactively, enter a Lisp object for VALUE.
If you want VALUE to be a string, you must surround it with doublequotes.
VALUE is used literally, not evaluated.
If VARIABLE has a `variable-interactive' property, that is used as if
it were the arg to `interactive' (which see) to interactively read VALUE.
If VARIABLE has been defined with `defcustom', then the type information
in the definition is used to check that VALUE is valid.
With a prefix argument, set VARIABLE to VALUE buffer-locally."
This caused the following confusion: A user logged onto the #emacs irc
channel and asked why the variable frame-title-format was not listed
in the tab-completion for M-x set-variable.
This means that we have at least one case of someone being confused be
this. Since the name of the function is "set-variable", the limited
scope is not immediately clear.
--
"Cut your own wood and it will warm you twice"
Regards, Yoni Rabkin Katzenell
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-19 11:14 Documentation not clear for the Lisp function set-variable Yoni Rabkin
@ 2005-06-20 3:50 ` Richard Stallman
2005-06-20 8:21 ` Yoni Rabkin
` (2 more replies)
0 siblings, 3 replies; 47+ messages in thread
From: Richard Stallman @ 2005-06-20 3:50 UTC (permalink / raw
Cc: emacs-devel
How about this doc string?
(defun set-variable (var val &optional make-local)
"Set VARIABLE to VALUE. VALUE is a Lisp object.
VARIABLE should be a user option variable name, a Lisp variable
meant to be customized by users. You should enter VALUE in Lisp syntax,
so if you want VALUE to be a string, you must surround it with doublequotes.
VALUE is used literally, not evaluated.
If VARIABLE has a `variable-interactive' property, that is used as if
it were the arg to `interactive' (which see) to interactively read VALUE.
If VARIABLE has been defined with `defcustom', then the type information
in the definition is used to check that VALUE is valid.
With a prefix argument, set VARIABLE to VALUE buffer-locally."
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-20 3:50 ` Richard Stallman
@ 2005-06-20 8:21 ` Yoni Rabkin
2005-06-20 9:07 ` Juanma Barranquero
2005-06-26 23:23 ` Juri Linkov
2 siblings, 0 replies; 47+ messages in thread
From: Yoni Rabkin @ 2005-06-20 8:21 UTC (permalink / raw
On 6/20/05, Richard Stallman <rms@gnu.org> wrote:
> How about this doc string?
>
> (defun set-variable (var val &optional make-local)
> "Set VARIABLE to VALUE. VALUE is a Lisp object.
> VARIABLE should be a user option variable name, a Lisp variable
> meant to be customized by users. You should enter VALUE in Lisp syntax,
> so if you want VALUE to be a string, you must surround it with doublequotes.
> VALUE is used literally, not evaluated.
[Snip]
I think that the above is a good doc string. The doc string states
clearly what VARIABLE is supposed to be.
--
"Cut your own wood and it will warm you twice"
Regards, Yoni Rabkin Katzenell
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-20 3:50 ` Richard Stallman
2005-06-20 8:21 ` Yoni Rabkin
@ 2005-06-20 9:07 ` Juanma Barranquero
2005-06-21 2:00 ` Richard Stallman
2005-06-26 23:23 ` Juri Linkov
2 siblings, 1 reply; 47+ messages in thread
From: Juanma Barranquero @ 2005-06-20 9:07 UTC (permalink / raw
Cc: emacs-devel
On 6/20/05, Richard Stallman <rms@gnu.org> wrote:
> How about this doc string?
>
> (defun set-variable (var val &optional make-local)
> "Set VARIABLE to VALUE. VALUE is a Lisp object.
[...]
If you change the docstring, it'd be great to also change the argument
names to match the ones in the docstring, or at least to add \(fn
VARIABLE VALUE &optional MAKE-LOCAL).
--
/L/e/k/t/u
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-20 9:07 ` Juanma Barranquero
@ 2005-06-21 2:00 ` Richard Stallman
0 siblings, 0 replies; 47+ messages in thread
From: Richard Stallman @ 2005-06-21 2:00 UTC (permalink / raw
Cc: emacs-devel
If you change the docstring, it'd be great to also change the argument
names to match the ones in the docstring, or at least to add \(fn
VARIABLE VALUE &optional MAKE-LOCAL).
Ok, I will. Thanks.
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-20 3:50 ` Richard Stallman
2005-06-20 8:21 ` Yoni Rabkin
2005-06-20 9:07 ` Juanma Barranquero
@ 2005-06-26 23:23 ` Juri Linkov
2005-06-27 13:04 ` Juanma Barranquero
2005-06-27 16:46 ` Richard M. Stallman
2 siblings, 2 replies; 47+ messages in thread
From: Juri Linkov @ 2005-06-26 23:23 UTC (permalink / raw
Cc: yonirabkin, emacs-devel
> How about this doc string?
>
> (defun set-variable (var val &optional make-local)
> "Set VARIABLE to VALUE. VALUE is a Lisp object.
> VARIABLE should be a user option variable name, a Lisp variable
> meant to be customized by users. You should enter VALUE in Lisp syntax,
> so if you want VALUE to be a string, you must surround it with doublequotes.
> VALUE is used literally, not evaluated.
>
> If VARIABLE has a `variable-interactive' property, that is used as if
> it were the arg to `interactive' (which see) to interactively read VALUE.
>
> If VARIABLE has been defined with `defcustom', then the type information
> in the definition is used to check that VALUE is valid.
>
> With a prefix argument, set VARIABLE to VALUE buffer-locally."
There is one problem with `set-variable'. When called interactively
it doesn't accept aliased user options. For example,
M-x set-variable RET messages-buffer-max-lines RET
reports that there are no matches, whereas `messages-buffer-max-lines'
is a valid alias for `message-log-max'. IMO, `set-variable' should
accept an alias when it is not marked as obsolete.
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-26 23:23 ` Juri Linkov
@ 2005-06-27 13:04 ` Juanma Barranquero
2005-06-27 15:44 ` Juanma Barranquero
` (2 more replies)
2005-06-27 16:46 ` Richard M. Stallman
1 sibling, 3 replies; 47+ messages in thread
From: Juanma Barranquero @ 2005-06-27 13:04 UTC (permalink / raw
Cc: rms, emacs-devel
On 6/27/05, Juri Linkov <juri@jurta.org> wrote:
> IMO, `set-variable' should
> accept an alias when it is not marked as obsolete.
Try this patch, please. It doesn't modify `set-variable' but
`user-variable-p', so it returns t for non-obsolete aliases of user
variables.
(Anyway, is that a new feature or a bug fix?)
--
/L/e/k/t/u
Index: src/eval.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/eval.c,v
retrieving revision 1.245
diff -u -2 -r1.245 eval.c
--- src/eval.c 27 Jun 2005 05:59:23 -0000 1.245
+++ src/eval.c 27 Jun 2005 13:03:26 -0000
@@ -94,4 +94,5 @@
Lisp_Object Qdebug_on_error;
Lisp_Object Qdeclare;
+Lisp_Object Qbyte_obsolete_variable;
/* This holds either the symbol `run-hooks' or nil.
@@ -894,10 +895,12 @@
\(The alternative is a variable used internally in a Lisp program.)
Determined by whether the first character of the documentation
-for the variable is `*' or if the variable is customizable (has a non-nil
-value of `standard-value' or of `custom-autoload' on its property list). */)
+for the variable is `*', the variable is customizable (has a non-nil
+value of `standard-value' or of `custom-autoload' on its property list),
+or it is a non-obsolete alias for another user variable. */)
(variable)
Lisp_Object variable;
{
Lisp_Object documentation;
+ struct Lisp_Symbol *sym;
if (!SYMBOLP (variable))
@@ -920,4 +923,10 @@
|| (!NILP (Fget (variable, intern ("custom-autoload")))))
return Qt;
+
+ sym = XSYMBOL (variable);
+ if (sym->indirect_variable
+ && NILP (Fget (variable, Qbyte_obsolete_variable)))
+ return Fuser_variable_p (sym->value);
+
return Qnil;
}
@@ -3410,4 +3419,7 @@
staticpro (&Qdeclare);
+ Qbyte_obsolete_variable = intern ("byte-obsolete-variable");
+ staticpro (&Qbyte_obsolete_variable);
+
/* Note that the process handling also uses Qexit, but we don't want
to staticpro it twice, so we just do it here. */
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-27 13:04 ` Juanma Barranquero
@ 2005-06-27 15:44 ` Juanma Barranquero
2005-06-27 16:09 ` Luc Teirlinck
2005-06-27 18:39 ` Eli Zaretskii
2005-06-28 4:17 ` Richard M. Stallman
2 siblings, 1 reply; 47+ messages in thread
From: Juanma Barranquero @ 2005-06-27 15:44 UTC (permalink / raw
Cc: rms, emacs-devel
On 6/27/05, Juanma Barranquero <lekktu@gmail.com> wrote:
> Try this patch, please. It doesn't modify `set-variable' but
> `user-variable-p', so it returns t for non-obsolete aliases of user
> variables.
Well, it is also necessary to detect alias loops. The problem is:
what should `user-variable-p' do when passed a variable which is in an
alias loop? Throw an error or return nil? I prefer the latter, as
`user-variable-p' is almost always used as predicate to completion
functions, apropos* or `mapatoms', where throwing an error would be
inappropriate.
--
/L/e/k/t/u
Index: src/eval.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/eval.c,v
retrieving revision 1.245
diff -u -2 -r1.245 eval.c
--- src/eval.c 27 Jun 2005 05:59:23 -0000 1.245
+++ src/eval.c 27 Jun 2005 15:37:53 -0000
@@ -94,4 +94,5 @@
Lisp_Object Qdebug_on_error;
Lisp_Object Qdeclare;
+Lisp_Object Qbyte_obsolete_variable;
/* This holds either the symbol `run-hooks' or nil.
@@ -890,18 +891,35 @@
}
+/* Error handler used in Fuser_variable_p. */
+static Lisp_Object
+user_variable_p_eh (ignore)
+ Lisp_Object ignore;
+{
+ return Qnil;
+}
+
DEFUN ("user-variable-p", Fuser_variable_p, Suser_variable_p, 1, 1, 0,
doc: /* Returns t if VARIABLE is intended to be set and
modified by users.
\(The alternative is a variable used internally in a Lisp program.)
Determined by whether the first character of the documentation
-for the variable is `*' or if the variable is customizable (has a non-nil
-value of `standard-value' or of `custom-autoload' on its property list). */)
+for the variable is `*', the variable is customizable (has a non-nil
+value of `standard-value' or of `custom-autoload' on its property list),
+or it is a non-obsolete alias for another user variable. */)
(variable)
Lisp_Object variable;
{
Lisp_Object documentation;
+ struct Lisp_Symbol *sym;
if (!SYMBOLP (variable))
return Qnil;
+ sym = XSYMBOL (variable);
+ /* If indirect and there's an alias loop, don't check anything else. */
+ if (sym->indirect_variable
+ && NILP (internal_condition_case_1 (indirect_variable, variable,
+ Qt, user_variable_p_eh)))
+ return Qnil;
+
documentation = Fget (variable, Qvariable_documentation);
if (INTEGERP (documentation) && XINT (documentation) < 0)
@@ -916,8 +934,15 @@
&& XINT (XCDR (documentation)) < 0)
return Qt;
- /* Customizable? See `custom-variable-p'. */
+ /* Customizable? See `custom-variable-p'. */
if ((!NILP (Fget (variable, intern ("standard-value"))))
|| (!NILP (Fget (variable, intern ("custom-autoload")))))
return Qt;
+
+ /* An indirect variable? Let's follow the chain. */
+ sym = XSYMBOL (variable);
+ if (sym->indirect_variable
+ && NILP (Fget (variable, Qbyte_obsolete_variable)))
+ return Fuser_variable_p (sym->value);
+
return Qnil;
}
@@ -3410,4 +3435,7 @@
staticpro (&Qdeclare);
+ Qbyte_obsolete_variable = intern ("byte-obsolete-variable");
+ staticpro (&Qbyte_obsolete_variable);
+
/* Note that the process handling also uses Qexit, but we don't want
to staticpro it twice, so we just do it here. */
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-27 15:44 ` Juanma Barranquero
@ 2005-06-27 16:09 ` Luc Teirlinck
2005-06-27 18:17 ` Juanma Barranquero
0 siblings, 1 reply; 47+ messages in thread
From: Luc Teirlinck @ 2005-06-27 16:09 UTC (permalink / raw
Cc: juri, rms, emacs-devel
You might want to try out `customize-face(-other-window)' and see how
it handles face aliases. (This behavior has been changed relatively
recently.) I believe that I will adapt `customize-variable' and
`customize-variable-other-window' to follow the new
`customize-face(-other-window)' behavior. (This is not done yet.)
I do not know whether or not it is important for `set-variable' to be
consistent with that. Maybe not. I just wanted to be sure that you
are aware of the `customize' situation.
Sincerely,
Luc.
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-26 23:23 ` Juri Linkov
2005-06-27 13:04 ` Juanma Barranquero
@ 2005-06-27 16:46 ` Richard M. Stallman
1 sibling, 0 replies; 47+ messages in thread
From: Richard M. Stallman @ 2005-06-27 16:46 UTC (permalink / raw
Cc: yonirabkin, emacs-devel
There is one problem with `set-variable'. When called interactively
it doesn't accept aliased user options.
It should accept aliases, even if they are obsolete. Could you fix that?
(It would be useful to notify the user that the name he used is an alias.)
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-27 16:09 ` Luc Teirlinck
@ 2005-06-27 18:17 ` Juanma Barranquero
2005-06-27 18:45 ` Luc Teirlinck
2005-06-28 0:07 ` Juri Linkov
0 siblings, 2 replies; 47+ messages in thread
From: Juanma Barranquero @ 2005-06-27 18:17 UTC (permalink / raw
Cc: emacs-devel
> I do not know whether or not it is important for `set-variable' to be
> consistent with that. Maybe not. I just wanted to be sure that you
> are aware of the `customize' situation.
AFAICS, customize-face does nothing special, other than filtering out
aliases (but accepts them if the user types them). The set-variable
situation is very different: it does not accept a variable name unless
it thinks it is a user-variable, so the easiest answer is just making
it believe that aliases of user-variables are also user-variables.
This will generate more answers in the completion list; I'm not sure
whether that is a problem or not (I tend to think that it is not, as
the list is pruned quite quickly as the user types in characters).
--
/L/e/k/t/u
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-27 13:04 ` Juanma Barranquero
2005-06-27 15:44 ` Juanma Barranquero
@ 2005-06-27 18:39 ` Eli Zaretskii
2005-06-27 18:49 ` Luc Teirlinck
2005-06-27 21:38 ` Juanma Barranquero
2005-06-28 4:17 ` Richard M. Stallman
2 siblings, 2 replies; 47+ messages in thread
From: Eli Zaretskii @ 2005-06-27 18:39 UTC (permalink / raw
Cc: emacs-devel
> Date: Mon, 27 Jun 2005 15:04:58 +0200
> From: Juanma Barranquero <lekktu@gmail.com>
> Cc: rms@gnu.org, emacs-devel@gnu.org
>
> Try this patch, please. It doesn't modify `set-variable' but
> `user-variable-p', so it returns t for non-obsolete aliases of user
> variables.
This patch produces the following text:
Determined by whether the first character of the documentation
for the variable is `*', the variable is customizable (has a non-nil
value of `standard-value' or of `custom-autoload' on its property list),
or it is a non-obsolete alias for another user variable.
Does anyone else think that this sentence is so confusing in its
structure as to be almost unparsable? (The old sentence was even less
clear.)
I think this sentence sorely needs rephrasing. For starters, it
should not use passive tense.
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-27 18:17 ` Juanma Barranquero
@ 2005-06-27 18:45 ` Luc Teirlinck
2005-06-27 19:30 ` Juanma Barranquero
2005-06-28 18:47 ` Richard M. Stallman
2005-06-28 0:07 ` Juri Linkov
1 sibling, 2 replies; 47+ messages in thread
From: Luc Teirlinck @ 2005-06-27 18:45 UTC (permalink / raw
Cc: emacs-devel
Juanma Barranquero wrote:
AFAICS, customize-face does nothing special, other than filtering out
aliases (but accepts them if the user types them).
`M-x customize-face RET diary-face' brings uo a customization buffer
for the face `diary' instead of for the typed alias `diary-face'.
_Assuming_, of course, that diary is loaded. If not, customize-face
will not recognize diary, nor diary-face. I proposed doing something
similar for customize-variable.
Sincerely,
Luc.
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-27 18:39 ` Eli Zaretskii
@ 2005-06-27 18:49 ` Luc Teirlinck
2005-06-27 21:38 ` Juanma Barranquero
1 sibling, 0 replies; 47+ messages in thread
From: Luc Teirlinck @ 2005-06-27 18:49 UTC (permalink / raw
Cc: lekktu, emacs-devel
Eli Zaretskii wrote:
This patch produces the following text:
Determined by whether the first character of the documentation
for the variable is `*', the variable is customizable (has a non-nil
value of `standard-value' or of `custom-autoload' on its property list),
or it is a non-obsolete alias for another user variable.
Does anyone else think that this sentence is so confusing in its
structure as to be almost unparsable? (The old sentence was even less
clear.)
I believe that it is also incorrect. I believe that we decided that a
variable was customizable if either its docstring starts with `*' or
it is defined with defcustom.
Unless I misunderstood or misremember, we decided that `*' was no
lomger necessary for variables defined with defcustom.
Sincerely,
Luc.
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-27 18:45 ` Luc Teirlinck
@ 2005-06-27 19:30 ` Juanma Barranquero
2005-06-28 18:47 ` Richard M. Stallman
1 sibling, 0 replies; 47+ messages in thread
From: Juanma Barranquero @ 2005-06-27 19:30 UTC (permalink / raw
Cc: emacs-devel
> `M-x customize-face RET diary-face' brings uo a customization buffer
> for the face `diary' instead of for the typed alias `diary-face'.
> _Assuming_, of course, that diary is loaded. If not, customize-face
> will not recognize diary, nor diary-face.
As set-variable is not bringing any buffer, selecting X or ALIAS-OF-X
to set should be similar.
--
/L/e/k/t/u
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-27 18:39 ` Eli Zaretskii
2005-06-27 18:49 ` Luc Teirlinck
@ 2005-06-27 21:38 ` Juanma Barranquero
2005-06-28 4:37 ` Eli Zaretskii
1 sibling, 1 reply; 47+ messages in thread
From: Juanma Barranquero @ 2005-06-27 21:38 UTC (permalink / raw
Cc: emacs-devel
> This patch produces the following text:
>
> Determined by whether the first character of the documentation
> for the variable is `*', the variable is customizable (has a non-nil
> value of `standard-value' or of `custom-autoload' on its property list),
> or it is a non-obsolete alias for another user variable.
>
> Does anyone else think that this sentence is so confusing in its
> structure as to be almost unparsable? (The old sentence was even less
> clear.)
Unparsable I wouldn't say, but certainly not very good. But anyway,
Richard just said that obsolete aliases should be set-variable too.
> I think this sentence sorely needs rephrasing. For starters, it
> should not use passive tense.
What about this patch? Do you like it a bit more?
--
/L/e/k/t/u
Index: src/eval.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/eval.c,v
retrieving revision 1.245
diff -u -2 -r1.245 eval.c
--- src/eval.c 27 Jun 2005 05:59:23 -0000 1.245
+++ src/eval.c 27 Jun 2005 21:32:36 -0000
@@ -890,10 +890,22 @@
}
+/* Error handler used in Fuser_variable_p. */
+static Lisp_Object
+user_variable_p_eh (ignore)
+ Lisp_Object ignore;
+{
+ return Qnil;
+}
+
DEFUN ("user-variable-p", Fuser_variable_p, Suser_variable_p, 1, 1, 0,
- doc: /* Returns t if VARIABLE is intended to be set and
modified by users.
+ doc: /* Return t if VARIABLE is intended to be set and
modified by users.
\(The alternative is a variable used internally in a Lisp program.)
-Determined by whether the first character of the documentation
-for the variable is `*' or if the variable is customizable (has a non-nil
-value of `standard-value' or of `custom-autoload' on its property list). */)
+VARIABLE is considered to be a `user variable' if
+\(1) the first character of its documentation is `*', or
+\(2) it is customizable (its property list contains a non-nil value
+ of `standard-value' or `custom-autoload'), or
+\(3) it is an alias for another user variable.
+Return nil if VARIABLE is an alias and there is a loop in the
+chain of symbols. */)
(variable)
Lisp_Object variable;
@@ -904,21 +916,35 @@
return Qnil;
- documentation = Fget (variable, Qvariable_documentation);
- if (INTEGERP (documentation) && XINT (documentation) < 0)
- return Qt;
- if (STRINGP (documentation)
- && ((unsigned char) SREF (documentation, 0) == '*'))
- return Qt;
- /* If it is (STRING . INTEGER), a negative integer means a user variable. */
- if (CONSP (documentation)
- && STRINGP (XCAR (documentation))
- && INTEGERP (XCDR (documentation))
- && XINT (XCDR (documentation)) < 0)
- return Qt;
- /* Customizable? See `custom-variable-p'. */
- if ((!NILP (Fget (variable, intern ("standard-value"))))
- || (!NILP (Fget (variable, intern ("custom-autoload")))))
- return Qt;
- return Qnil;
+ /* If indirect and there's an alias loop, don't check anything else. */
+ if (XSYMBOL (variable)->indirect_variable
+ && NILP (internal_condition_case_1 (indirect_variable, variable,
+ Qt, user_variable_p_eh)))
+ return Qnil;
+
+ while (1)
+ {
+ documentation = Fget (variable, Qvariable_documentation);
+ if (INTEGERP (documentation) && XINT (documentation) < 0)
+ return Qt;
+ if (STRINGP (documentation)
+ && ((unsigned char) SREF (documentation, 0) == '*'))
+ return Qt;
+ /* If it is (STRING . INTEGER), a negative integer means a user
variable. */
+ if (CONSP (documentation)
+ && STRINGP (XCAR (documentation))
+ && INTEGERP (XCDR (documentation))
+ && XINT (XCDR (documentation)) < 0)
+ return Qt;
+ /* Customizable? See `custom-variable-p'. */
+ if ((!NILP (Fget (variable, intern ("standard-value"))))
+ || (!NILP (Fget (variable, intern ("custom-autoload")))))
+ return Qt;
+
+ if (!XSYMBOL (variable)->indirect_variable)
+ return Qnil;
+
+ /* An indirect variable? Let's follow the chain. */
+ variable = XSYMBOL (variable)->value;
+ }
}
\f
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-27 18:17 ` Juanma Barranquero
2005-06-27 18:45 ` Luc Teirlinck
@ 2005-06-28 0:07 ` Juri Linkov
2005-06-28 8:32 ` Juanma Barranquero
2005-06-28 18:47 ` Richard M. Stallman
1 sibling, 2 replies; 47+ messages in thread
From: Juri Linkov @ 2005-06-28 0:07 UTC (permalink / raw
Cc: teirllm, emacs-devel
>> I do not know whether or not it is important for `set-variable' to be
>> consistent with that. Maybe not. I just wanted to be sure that you
>> are aware of the `customize' situation.
>
> AFAICS, customize-face does nothing special, other than filtering out
> aliases (but accepts them if the user types them). The set-variable
> situation is very different: it does not accept a variable name unless
> it thinks it is a user-variable, so the easiest answer is just making
> it believe that aliases of user-variables are also user-variables.
> This will generate more answers in the completion list; I'm not sure
> whether that is a problem or not (I tend to think that it is not, as
> the list is pruned quite quickly as the user types in characters).
Maybe set-variable should first try to complete non-obsolete aliases,
and filter out obsolete aliases (but still accept them). The distinction
between obsolete variables and aliases is essential. Users should not
see obsolete variables by default, but should be able to use them
(with possible notification about their obsoleteness). Aliases are
valid names just like the variable names they refer to.
Also it makes sense to introduce a new property byte-obsolete-face
to mark obsolete faces, so completion would work similarly for
customize-face.
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-27 13:04 ` Juanma Barranquero
2005-06-27 15:44 ` Juanma Barranquero
2005-06-27 18:39 ` Eli Zaretskii
@ 2005-06-28 4:17 ` Richard M. Stallman
2005-06-28 9:17 ` Juanma Barranquero
2 siblings, 1 reply; 47+ messages in thread
From: Richard M. Stallman @ 2005-06-28 4:17 UTC (permalink / raw
Cc: juri, emacs-devel
Try this patch, please. It doesn't modify `set-variable' but
`user-variable-p', so it returns t for non-obsolete aliases of user
variables.
Please install your patch.
(Anyway, is that a new feature or a bug fix?)
It is a bug fix.
Would you like to change set-variable to give a warning
when the argument given is an alias?
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-27 21:38 ` Juanma Barranquero
@ 2005-06-28 4:37 ` Eli Zaretskii
2005-06-28 8:33 ` Juanma Barranquero
0 siblings, 1 reply; 47+ messages in thread
From: Eli Zaretskii @ 2005-06-28 4:37 UTC (permalink / raw
Cc: emacs-devel
> Date: Mon, 27 Jun 2005 23:38:52 +0200
> From: Juanma Barranquero <lekktu@gmail.com>
> Cc: emacs-devel@gnu.org
>
> What about this patch? Do you like it a bit more?
>
> +VARIABLE is considered to be a `user variable' if
> +\(1) the first character of its documentation is `*', or
> +\(2) it is customizable (its property list contains a non-nil value
> + of `standard-value' or `custom-autoload'), or
> +\(3) it is an alias for another user variable.
> +Return nil if VARIABLE is an alias and there is a loop in the
> +chain of symbols. */)
It is better, but I think if you start the sentence with
A variable is a user variable if
it would be better yet.
Thanks.
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-28 0:07 ` Juri Linkov
@ 2005-06-28 8:32 ` Juanma Barranquero
2005-06-28 23:45 ` Juri Linkov
2005-06-28 18:47 ` Richard M. Stallman
1 sibling, 1 reply; 47+ messages in thread
From: Juanma Barranquero @ 2005-06-28 8:32 UTC (permalink / raw
Cc: emacs-devel
On 6/28/05, Juri Linkov <juri@jurta.org> wrote:
> Maybe set-variable should first try to complete non-obsolete aliases,
> and filter out obsolete aliases (but still accept them).
Completing to all non-obsolete variables and/or aliases should be
easy, but... [see below]
> The distinction
> between obsolete variables and aliases is essential. Users should not
> see obsolete variables by default, but should be able to use them
...I don't buy this argument. Users do not go randomly typing chars
into `set-variable' just to see what variables they can set (at least,
I don't think that's the most common use pattern). IMO, the user does
M-x set-variable because he already knows the variable he wants to set
(and it's even likely he read the doc and knows whether it is obsolete
or not, though I'm willing to accept there are users who simply set a
variable because they read about it in an old doc somewhere) and
completion is just a help to do less typing. So in my view,
`set-variable' should not filter out any user variable, whether it is
an obsolete variable or an obsolete alias. I certainly would be very
pissed if I wanted to set `messages-buffer-max-lines' and had to type
it fully because `set-variable' had decided that `message-log-max' was
the way to go.
> (with possible notification about their obsoleteness).
That's another matter entirely. I think is a good idea to warn about
the variable being obsolete. But with the current `completing-read'
mechanism, that can no be easily and elegantly done while the user is
selecting the variable, only afterwards (unless I'm missing
something).
> Also it makes sense to introduce a new property byte-obsolete-face
> to mark obsolete faces, so completion would work similarly for
> customize-face.
I support the idea about byte-obsolete-face, but not for face
completion's sake, but because perhaps the byte-compiler could be
coaxed into giving warnings about old faces' uses.
Anyway, I'm not planning to delve into face completion (or customize),
so that's a matter for whomever wants to implement it to ponder.
--
/L/e/k/t/u
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-28 4:37 ` Eli Zaretskii
@ 2005-06-28 8:33 ` Juanma Barranquero
0 siblings, 0 replies; 47+ messages in thread
From: Juanma Barranquero @ 2005-06-28 8:33 UTC (permalink / raw
Cc: emacs-devel
On 6/28/05, Eli Zaretskii <eliz@gnu.org> wrote:
> A variable is a user variable if
>
> it would be better yet.
OK, I've fixed my patch. Thanks.
--
/L/e/k/t/u
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-28 4:17 ` Richard M. Stallman
@ 2005-06-28 9:17 ` Juanma Barranquero
2005-06-28 9:26 ` Juanma Barranquero
` (2 more replies)
0 siblings, 3 replies; 47+ messages in thread
From: Juanma Barranquero @ 2005-06-28 9:17 UTC (permalink / raw
Cc: juri, emacs-devel
On 6/28/05, Richard M. Stallman <rms@gnu.org> wrote:
> Please install your patch.
After all this discussion, I'm not sure what's to be installed, so let
me recapitulate. The patch below modifies `user-variable-p' so it
also considers as user variables these aliases that point, directly or
indirectly, to other user variables; that includes also obsolete
aliases, I'm not filtering them out. It also returns nil for alias
loops, irrespective of whether any of the aliases in the loop would
qualify as a user variable or not.
This patch fixes the problem originally reported by Juri, i.e., that
`set-variable' didn't allow setting aliases to user options.
Questions remaining:
- Is there a consensus whether obsolete aliases should be shown or
not? In a recent message Juri proposed that obsolete aliases were not
shown by default, but could be set anyway. Currently `set-variable'
does not accept unknown variable names (to prevent the user setting
misspelled variables, I suppose). Doing what Juri proposes would mean
either changing that, or modifying `read-variable' to check after the
fact whether a given symbol is an obsolete alias or not; all that for
no clear added benefit, and with the added inconvenience that the user
will end typing more if he really wants to set an obsolete alias and
not the current variable the alias points to.
- It is OK for `user-variable-p' to return nil for alias loops
instead of signaling an error? I think yes because `user-variable-p'
is not a user command, ant its main use is with `mapatoms' and
completion, where the idea is filtering out uninteresting variables.
- Should `set-variable' give warnings for all aliases, for obsolete
aliases only? Should o it for obsolete variables even if they aren't
aliases?
- What's the right moment to give the warning? Before setting the
value or after it?
Sorry for being so prolix, but I prefer to ask everything and try to
avoid multi-headed hydras... er, threads where no clear conclusion is
reached :)
--
/L/e/k/t/u
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-28 9:17 ` Juanma Barranquero
@ 2005-06-28 9:26 ` Juanma Barranquero
2005-06-28 16:09 ` Stefan Monnier
2005-06-29 3:59 ` Richard M. Stallman
2 siblings, 0 replies; 47+ messages in thread
From: Juanma Barranquero @ 2005-06-28 9:26 UTC (permalink / raw
Cc: juri, emacs-devel
> The patch below modifies `user-variable-p' [etc, etc.]
That would be more convincing if I really attached the patch...
(BTW, the patch uses diff -b because most of user-visible-p is now
inside a while loop, but otherwise unchanged.)
--
/L/e/k/t/u
Index: src/eval.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/eval.c,v
retrieving revision 1.246
diff -b -c -2 -r1.246 eval.c
*** src/eval.c 28 Jun 2005 02:27:38 -0000 1.246
--- src/eval.c 28 Jun 2005 08:34:08 -0000
***************
*** 890,899 ****
}
DEFUN ("user-variable-p", Fuser_variable_p, Suser_variable_p, 1, 1, 0,
! doc: /* Returns t if VARIABLE is intended to be set and
modified by users.
\(The alternative is a variable used internally in a Lisp program.)
! Determined by whether the first character of the documentation
! for the variable is `*' or if the variable is customizable (has a non-nil
! value of `standard-value' or of `custom-autoload' on its property list). */)
(variable)
Lisp_Object variable;
--- 890,911 ----
}
+ /* Error handler used in Fuser_variable_p. */
+ static Lisp_Object
+ user_variable_p_eh (ignore)
+ Lisp_Object ignore;
+ {
+ return Qnil;
+ }
+
DEFUN ("user-variable-p", Fuser_variable_p, Suser_variable_p, 1, 1, 0,
! doc: /* Return t if VARIABLE is intended to be set and
modified by users.
\(The alternative is a variable used internally in a Lisp program.)
! A variable is a user variable if
! \(1) the first character of its documentation is `*', or
! \(2) it is customizable (its property list contains a non-nil value
! of `standard-value' or `custom-autoload'), or
! \(3) it is an alias for another user variable.
! Return nil if VARIABLE is an alias and there is a loop in the
! chain of symbols. */)
(variable)
Lisp_Object variable;
***************
*** 904,907 ****
--- 916,927 ----
return Qnil;
+ /* If indirect and there's an alias loop, don't check anything else. */
+ if (XSYMBOL (variable)->indirect_variable
+ && NILP (internal_condition_case_1 (indirect_variable, variable,
+ Qt, user_variable_p_eh)))
+ return Qnil;
+
+ while (1)
+ {
documentation = Fget (variable, Qvariable_documentation);
if (INTEGERP (documentation) && XINT (documentation) < 0)
***************
*** 920,924 ****
--- 940,950 ----
|| (!NILP (Fget (variable, intern ("custom-autoload")))))
return Qt;
+
+ if (!XSYMBOL (variable)->indirect_variable)
return Qnil;
+
+ /* An indirect variable? Let's follow the chain. */
+ variable = XSYMBOL (variable)->value;
+ }
}
\f
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-28 9:17 ` Juanma Barranquero
2005-06-28 9:26 ` Juanma Barranquero
@ 2005-06-28 16:09 ` Stefan Monnier
2005-06-28 16:19 ` Juanma Barranquero
2005-06-29 3:59 ` Richard M. Stallman
2 siblings, 1 reply; 47+ messages in thread
From: Stefan Monnier @ 2005-06-28 16:09 UTC (permalink / raw
Cc: juri, rms, emacs-devel
> - Is there a consensus whether obsolete aliases should be shown or
> not? In a recent message Juri proposed that obsolete aliases were not
> shown by default, but could be set anyway. Currently `set-variable'
> does not accept unknown variable names (to prevent the user setting
> misspelled variables, I suppose). Doing what Juri proposes would mean
> either changing that, or modifying `read-variable' to check after the
> fact whether a given symbol is an obsolete alias or not; all that for
> no clear added benefit, and with the added inconvenience that the user
> will end typing more if he really wants to set an obsolete alias and
> not the current variable the alias points to.
I think we should use the complete-in-turn thingy so that completion first
tries to complete without obsolete vars and only if that fails then it tries
to complete with obsolete vars.
> - It is OK for `user-variable-p' to return nil for alias loops
> instead of signaling an error?
Looks fine to me. If it's an alias loop, it's not a user-variable.
> - Should `set-variable' give warnings for all aliases, for obsolete
> aliases only? Should o it for obsolete variables even if they aren't
> aliases?
I recommend not to classify cases as "alias" and "obsolete alias"
but as "alias" and "obsolete" where this latter case can be an alias
or not. Setting an obsolete var should be discouraged, whether it's aliased
to some other var or not.
> - What's the right moment to give the warning? Before setting the
> value or after it?
If you want a warning for aliases, it should come after, in the same way as
the display of shortcuts after M-x foobar RET.
As for warnings of obsoleteness, I would argue to put them before (with
a (sit-for 1)), since we want to send a clear message that they should not
use this variable any more.
Stefan
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-28 16:09 ` Stefan Monnier
@ 2005-06-28 16:19 ` Juanma Barranquero
2005-06-29 3:43 ` Stefan Monnier
0 siblings, 1 reply; 47+ messages in thread
From: Juanma Barranquero @ 2005-06-28 16:19 UTC (permalink / raw
Cc: juri, rms, emacs-devel
> I think we should use the complete-in-turn thingy
Hmm. Some more info, please? :-)
> so that completion first
> tries to complete without obsolete vars and only if that fails then it tries
> to complete with obsolete vars.
OK, once I understand what are you referring to with the
"complete-in-turn thingy"...
> I recommend not to classify cases as "alias" and "obsolete alias"
> but as "alias" and "obsolete" where this latter case can be an alias
> or not. Setting an obsolete var should be discouraged, whether it's aliased
> to some other var or not.
OK, with respect to giving a warning (wrt completion I don't agree,
but I'll implement whatever is deemed best, of course).
> If you want a warning for aliases, it should come after, in the same way as
> the display of shortcuts after M-x foobar RET.
Where is that implemented?
> As for warnings of obsoleteness, I would argue to put them before (with
> a (sit-for 1)), since we want to send a clear message that they should not
> use this variable any more.
OK, makes sense.
If I understand correctly, you're OK'ing the `user-variable-p' patch
and we're now discussing patching `set-variable'.
--
/L/e/k/t/u
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-27 18:45 ` Luc Teirlinck
2005-06-27 19:30 ` Juanma Barranquero
@ 2005-06-28 18:47 ` Richard M. Stallman
2005-07-04 1:18 ` Luc Teirlinck
1 sibling, 1 reply; 47+ messages in thread
From: Richard M. Stallman @ 2005-06-28 18:47 UTC (permalink / raw
Cc: lekktu, emacs-devel
`M-x customize-face RET diary-face' brings uo a customization buffer
for the face `diary' instead of for the typed alias `diary-face'.
_Assuming_, of course, that diary is loaded. If not, customize-face
will not recognize diary, nor diary-face. I proposed doing something
similar for customize-variable.
I think it is right to use the "real" name rather than the alias in
the customization buffer, for variables as well as for faces.
So please do make that change in customize-variable.
As set-variable is not bringing any buffer, selecting X or ALIAS-OF-X
to set should be similar.
That is true; this issue doesn't arise for set-variable, only for
Custom buffers.
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-28 0:07 ` Juri Linkov
2005-06-28 8:32 ` Juanma Barranquero
@ 2005-06-28 18:47 ` Richard M. Stallman
2005-06-29 2:32 ` Juanma Barranquero
1 sibling, 1 reply; 47+ messages in thread
From: Richard M. Stallman @ 2005-06-28 18:47 UTC (permalink / raw
Cc: lekktu, teirllm, emacs-devel
Maybe set-variable should first try to complete non-obsolete aliases,
and filter out obsolete aliases (but still accept them).
I don't like that idea. The command should accept *all* names,
whether obsolete or not. But it would be nice to inform the user in
the echo area that the name is obsolete, and give the new name if any.
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-28 8:32 ` Juanma Barranquero
@ 2005-06-28 23:45 ` Juri Linkov
2005-06-29 9:14 ` Juanma Barranquero
0 siblings, 1 reply; 47+ messages in thread
From: Juri Linkov @ 2005-06-28 23:45 UTC (permalink / raw
Cc: emacs-devel
> IMO, the user does M-x set-variable because he already knows the
> variable he wants to set (and it's even likely he read the doc and
> knows whether it is obsolete or not, though I'm willing to accept
> there are users who simply set a variable because they read about it
> in an old doc somewhere) and completion is just a help to do less
> typing. So in my view, `set-variable' should not filter out any user
> variable, whether it is an obsolete variable or an obsolete
> alias. I certainly would be very pissed if I wanted to set
> `messages-buffer-max-lines' and had to type it fully because
> `set-variable' had decided that `message-log-max' was the way to go.
`messages-buffer-max-lines' is not an obsolete alias for
`message-log-max'. Rather it's the other way round: `message-log-max'
is an obsolete variable (thought it is not marked as such yet), but
its alias `messages-buffer-max-lines' is not obsolete (it was added
recently as a better name instead of `message-log-max'). But anyway
I see your point. I agree that filtering is not very necessary, and
think that it would be sufficient to display a warning for obsolete
variables and obsolete aliases after selecting the variable but before
setting its value.
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-28 18:47 ` Richard M. Stallman
@ 2005-06-29 2:32 ` Juanma Barranquero
2005-06-29 20:42 ` Richard M. Stallman
0 siblings, 1 reply; 47+ messages in thread
From: Juanma Barranquero @ 2005-06-29 2:32 UTC (permalink / raw
Cc: emacs-devel
On 6/28/05, Richard M. Stallman <rms@gnu.org> wrote:
> I don't like that idea. The command should accept *all* names,
> whether obsolete or not. But it would be nice to inform the user in
> the echo area that the name is obsolete, and give the new name if any.
With the installed changes for `user-variable-p' and the attached
patch, `set-variable' now:
- allows setting aliases of user options
- does *not* filter out obsolete variables
- shows a 3-seconds warning when the variable (alias or not) being
set is obsolete;
the warning includes the CURRENT-NAME information from
`make-variable-obsolete'
- does not show a warning for aliases (I don't think it's necessary
to single out aliases
if they aren't obsolete, and when they are, they already produce a warning)
--
/L/e/k/t/u
Index: lisp/simple.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/simple.el,v
retrieving revision 1.734
diff -c -2 -b -r1.734 simple.el
*** lisp/simple.el 24 Jun 2005 21:11:58 -0000 1.734
--- lisp/simple.el 29 Jun 2005 00:50:03 -0000
***************
*** 4539,4550 ****
(minibuffer-help-form '(describe-variable var))
(prop (get var 'variable-interactive))
! (prompt (format "Set %s%s to value: " var
(cond ((local-variable-p var)
! " (buffer-local)")
((or current-prefix-arg
(local-variable-if-set-p var))
! " buffer-locally")
! (t " globally"))))
! (val (if prop
;; Use VAR's `variable-interactive' property
;; as an interactive spec for prompting.
--- 4539,4557 ----
(minibuffer-help-form '(describe-variable var))
(prop (get var 'variable-interactive))
! (obsolete (car (get var 'byte-obsolete-variable)))
! (prompt (format "Set %s %s to value: " var
(cond ((local-variable-p var)
! "(buffer-local)")
((or current-prefix-arg
(local-variable-if-set-p var))
! "buffer-locally")
! (t "globally"))))
! (val (progn
! (when obsolete
! (message (concat "`%S' is obsolete; "
! (if (symbolp obsolete) "use `%S'
instead" "%s"))
! var obsolete)
! (sit-for 3))
! (if prop
;; Use VAR's `variable-interactive' property
;; as an interactive spec for prompting.
***************
*** 4554,4558 ****
(read
(read-string prompt nil
! 'set-variable-value-history)))))
(list var val current-prefix-arg)))
--- 4561,4565 ----
(read
(read-string prompt nil
! 'set-variable-value-history))))))
(list var val current-prefix-arg)))
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-28 16:19 ` Juanma Barranquero
@ 2005-06-29 3:43 ` Stefan Monnier
2005-06-29 9:18 ` Juanma Barranquero
0 siblings, 1 reply; 47+ messages in thread
From: Stefan Monnier @ 2005-06-29 3:43 UTC (permalink / raw
Cc: juri, rms, emacs-devel
>> I think we should use the complete-in-turn thingy
> Hmm. Some more info, please? :-)
C-h f complete-in-turn RET
Try C-s complete-in-turn in the lisp/ChangeLog file as well to see where
it's used.
> If I understand correctly, you're OK'ing the `user-variable-p' patch
> and we're now discussing patching `set-variable'.
AFAIC, the patch falls in the "obviously a bug-fix" category.
Stefan
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-28 9:17 ` Juanma Barranquero
2005-06-28 9:26 ` Juanma Barranquero
2005-06-28 16:09 ` Stefan Monnier
@ 2005-06-29 3:59 ` Richard M. Stallman
2 siblings, 0 replies; 47+ messages in thread
From: Richard M. Stallman @ 2005-06-29 3:59 UTC (permalink / raw
Cc: juri, emacs-devel
After all this discussion, I'm not sure what's to be installed, so let
me recapitulate. The patch below modifies `user-variable-p' so it
also considers as user variables these aliases that point, directly or
indirectly, to other user variables; that includes also obsolete
aliases, I'm not filtering them out. It also returns nil for alias
loops, irrespective of whether any of the aliases in the loop would
qualify as a user variable or not.
That all sounds right.
- Is there a consensus whether obsolete aliases should be shown or
not?
I am not sure what you mean by "shown". Obsolete aliases should
be accepted by user-variable-p.
- Should `set-variable' give warnings for all aliases, for obsolete
aliases only? Should o it for obsolete variables even if they aren't
aliases?
It should give warnings for all obsolete variables.
- What's the right moment to give the warning? Before setting the
value or after it?
It should be the last thing set-variable does.
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-28 23:45 ` Juri Linkov
@ 2005-06-29 9:14 ` Juanma Barranquero
2005-06-29 23:57 ` Juri Linkov
0 siblings, 1 reply; 47+ messages in thread
From: Juanma Barranquero @ 2005-06-29 9:14 UTC (permalink / raw
Cc: emacs-devel
On 6/29/05, Juri Linkov <juri@jurta.org> wrote:
> I agree that filtering is not very necessary, and
> think that it would be sufficient to display a warning for obsolete
> variables and obsolete aliases after selecting the variable but before
> setting its value.
Cool. That's what my latest patch does. Please take a look to see if
it matches your expectations.
--
/L/e/k/t/u
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-29 3:43 ` Stefan Monnier
@ 2005-06-29 9:18 ` Juanma Barranquero
0 siblings, 0 replies; 47+ messages in thread
From: Juanma Barranquero @ 2005-06-29 9:18 UTC (permalink / raw
Cc: emacs-devel
> C-h f complete-in-turn RET
Oops, sorry. As you casually said "the complete-in-turn thingy" I
(erroneously) assumed you were describing something, not giving the
precise name of the function :-)
Anyway, I've implemented the change to `set-variable' without it. You
seem to want the two-phase completion, and Richard seems not to (at
least that's how I interpreted his comments). So let's first decide
how we want `set-variable' to behave.
--
/L/e/k/t/u
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-29 2:32 ` Juanma Barranquero
@ 2005-06-29 20:42 ` Richard M. Stallman
0 siblings, 0 replies; 47+ messages in thread
From: Richard M. Stallman @ 2005-06-29 20:42 UTC (permalink / raw
Cc: emacs-devel
- allows setting aliases of user options
- does *not* filter out obsolete variables
- shows a 3-seconds warning when the variable (alias or not) being
set is obsolete;
the warning includes the CURRENT-NAME information from
`make-variable-obsolete'
- does not show a warning for aliases (I don't think it's necessary
to single out aliases
if they aren't obsolete, and when they are, they already produce a warning)
I think all of those are the right thing. Thanks.
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-29 9:14 ` Juanma Barranquero
@ 2005-06-29 23:57 ` Juri Linkov
2005-06-30 8:16 ` Juanma Barranquero
0 siblings, 1 reply; 47+ messages in thread
From: Juri Linkov @ 2005-06-29 23:57 UTC (permalink / raw
Cc: emacs-devel
>> I agree that filtering is not very necessary, and
>> think that it would be sufficient to display a warning for obsolete
>> variables and obsolete aliases after selecting the variable but before
>> setting its value.
>
> Cool. That's what my latest patch does. Please take a look to see if
> it matches your expectations.
I like it.
BTW, there is another problem in `set-variable'. When setting
a customizable variable with `set-variable' it doesn't use its
`:set' keyword to set the value. For example,
M-x set-variable RET frame-background-mode RET dark RET
doesn't update the background mode until `frame-set-background-mode'
is run explicitly.
`set-variable' already uses internal functions of the `custom' package
to test the custom type, so why wouldn't it also run a setter specified
by the `:set' custom keyword?
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-29 23:57 ` Juri Linkov
@ 2005-06-30 8:16 ` Juanma Barranquero
2005-06-30 16:55 ` Luc Teirlinck
0 siblings, 1 reply; 47+ messages in thread
From: Juanma Barranquero @ 2005-06-30 8:16 UTC (permalink / raw
Cc: emacs-devel
On 6/30/05, Juri Linkov <juri@jurta.org> wrote:
> so why wouldn't it also run a setter specified
> by the `:set' custom keyword?
It probably should. I'll take a look at it. I'm not custom expert,
though; I hardly use the stuff.
--
/L/e/k/t/u
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-30 8:16 ` Juanma Barranquero
@ 2005-06-30 16:55 ` Luc Teirlinck
2005-06-30 19:34 ` Juanma Barranquero
2005-07-01 23:57 ` Juri Linkov
0 siblings, 2 replies; 47+ messages in thread
From: Luc Teirlinck @ 2005-06-30 16:55 UTC (permalink / raw
Cc: juri, emacs-devel
Juanma Barranquero wrote:
On 6/30/05, Juri Linkov <juri@jurta.org> wrote:
> so why wouldn't it also run a setter specified
> by the `:set' custom keyword?
It probably should. I'll take a look at it. I'm not custom expert,
though; I hardly use the stuff.
I have not been following this thread. Are you discussing making
set-variable calling any :set function? We decided quite a while ago
to do that. But there are some subtleties involved, for instance with
buffer local variables. We decided to put it off till after the
release.
Sincerely,
Luc.
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-30 16:55 ` Luc Teirlinck
@ 2005-06-30 19:34 ` Juanma Barranquero
2005-07-01 23:57 ` Juri Linkov
1 sibling, 0 replies; 47+ messages in thread
From: Juanma Barranquero @ 2005-06-30 19:34 UTC (permalink / raw
Cc: juri, emacs-devel
On 6/30/05, Luc Teirlinck <teirllm@dms.auburn.edu> wrote:
> Are you discussing making
> set-variable calling any :set function?
Juri proposed that, yes.
> We decided quite a while ago to do that.
Glad to hear (because I won't have to implement it...)
> We decided to put it off till after the release.
Commendable :D
Thanks for clarifying this,
/L/e/k/t/u
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-30 16:55 ` Luc Teirlinck
2005-06-30 19:34 ` Juanma Barranquero
@ 2005-07-01 23:57 ` Juri Linkov
2005-07-02 4:11 ` Luc Teirlinck
1 sibling, 1 reply; 47+ messages in thread
From: Juri Linkov @ 2005-07-01 23:57 UTC (permalink / raw
Cc: lekktu, emacs-devel
> > so why wouldn't it also run a setter specified
> > by the `:set' custom keyword?
>
> It probably should. I'll take a look at it. I'm not custom expert,
> though; I hardly use the stuff.
>
> I have not been following this thread. Are you discussing making
> set-variable calling any :set function? We decided quite a while ago
> to do that. But there are some subtleties involved, for instance with
> buffer local variables. We decided to put it off till after the
> release.
I don't remember what the decision was, but if it was to postpone this
until the next release, then perhaps this should be added to etc/TODO.
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-07-01 23:57 ` Juri Linkov
@ 2005-07-02 4:11 ` Luc Teirlinck
0 siblings, 0 replies; 47+ messages in thread
From: Luc Teirlinck @ 2005-07-02 4:11 UTC (permalink / raw
Cc: lekktu, emacs-devel
Juri Linkov wrote:
I don't remember what the decision was, but if it was to postpone this
until the next release, then perhaps this should be added to etc/TODO.
We decided to put it off until after the release, because the exact
details of what we really wanted to do were not clear. There are
issues with buffer local variables and so on. So the item in TODO
could not even specify what needs to be done. There are several
fundamental issues about Custom which need to be decided first.
Sincerely,
Luc.
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-06-28 18:47 ` Richard M. Stallman
@ 2005-07-04 1:18 ` Luc Teirlinck
2005-07-04 16:48 ` Richard M. Stallman
0 siblings, 1 reply; 47+ messages in thread
From: Luc Teirlinck @ 2005-07-04 1:18 UTC (permalink / raw
Cc: lekktu, emacs-devel
Richard Stallman wrote:
I think it is right to use the "real" name rather than the alias in
the customization buffer, for variables as well as for faces.
So please do make that change in customize-variable.
Actually, I forgot that, unlike customize-face, customize-variable
does not allow to enter variables that are defvarred or defvaraliased,
rather than defcustomed. So the problem does not arise for variable
aliases. The person trying the alias will see that it does not
complete. After investigating the problem using `C-h v', he will see
that it is an alias and gets a link to customize the actual option.
Sincerely,
Luc.
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-07-04 1:18 ` Luc Teirlinck
@ 2005-07-04 16:48 ` Richard M. Stallman
2005-07-04 17:02 ` David Kastrup
2005-07-05 1:42 ` Luc Teirlinck
0 siblings, 2 replies; 47+ messages in thread
From: Richard M. Stallman @ 2005-07-04 16:48 UTC (permalink / raw
Cc: lekktu, emacs-devel
Actually, I forgot that, unlike customize-face, customize-variable
does not allow to enter variables that are defvarred or defvaraliased,
rather than defcustomed.
I think that is partly a bug--it should allow an alias if its "real"
name has a defcustom.
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-07-04 16:48 ` Richard M. Stallman
@ 2005-07-04 17:02 ` David Kastrup
2005-07-05 1:42 ` Luc Teirlinck
1 sibling, 0 replies; 47+ messages in thread
From: David Kastrup @ 2005-07-04 17:02 UTC (permalink / raw
Cc: lekktu, Luc Teirlinck, emacs-devel
"Richard M. Stallman" <rms@gnu.org> writes:
> Actually, I forgot that, unlike customize-face, customize-variable
> does not allow to enter variables that are defvarred or defvaraliased,
> rather than defcustomed.
>
> I think that is partly a bug--it should allow an alias if its "real"
> name has a defcustom.
But then it should go to the customize dialog for the "real"
variable. Everything else would be too confusing in the long run,
particularly if you are saving options in your .emacs file.
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-07-04 16:48 ` Richard M. Stallman
2005-07-04 17:02 ` David Kastrup
@ 2005-07-05 1:42 ` Luc Teirlinck
2005-07-05 16:12 ` Richard M. Stallman
1 sibling, 1 reply; 47+ messages in thread
From: Luc Teirlinck @ 2005-07-05 1:42 UTC (permalink / raw
Cc: lekktu, emacs-devel
Richard Stallman wrote:
Actually, I forgot that, unlike customize-face, customize-variable
does not allow to enter variables that are defvarred or defvaraliased,
rather than defcustomed.
I think that is partly a bug--it should allow an alias if its "real"
name has a defcustom.
If it is a bug, then the following patches fix it. I can install if
desired:
===File ~/custom-diff=======================================
diff -c /home/teirllm/emacscvsdir/emacs/lisp/custom.el.\~1.85.\~ /home/teirllm/emacscvsdir/emacs/lisp/custom.el
*** /home/teirllm/emacscvsdir/emacs/lisp/custom.el.~1.85.~ Sun Jul 3 13:38:33 2005
--- /home/teirllm/emacscvsdir/emacs/lisp/custom.el Mon Jul 4 19:45:29 2005
***************
*** 518,524 ****
;; This test is also in the C code of `user-variable-p'.
(defun custom-variable-p (variable)
! "Return non-nil if VARIABLE is a custom variable."
(or (get variable 'standard-value)
(get variable 'custom-autoload)))
--- 518,526 ----
;; This test is also in the C code of `user-variable-p'.
(defun custom-variable-p (variable)
! "Return non-nil if VARIABLE is a custom variable.
! This recursively follows aliases."
! (setq variable (indirect-variable variable))
(or (get variable 'standard-value)
(get variable 'custom-autoload)))
Diff finished. Mon Jul 4 20:23:04 2005
============================================================
===File ~/cus-edit-diff=====================================
diff -c /home/teirllm/emacscvsdir/emacs/lisp/cus-edit.el.\~1.225.\~ /home/teirllm/emacscvsdir/emacs/lisp/cus-edit.el
*** /home/teirllm/emacscvsdir/emacs/lisp/cus-edit.el.~1.225.~ Sun Jul 3 19:57:02 2005
--- /home/teirllm/emacscvsdir/emacs/lisp/cus-edit.el Mon Jul 4 19:45:23 2005
***************
*** 488,495 ****
(defun custom-variable-prompt ()
"Prompt for a custom variable, defaulting to the variable at point.
Return a list suitable for use in `interactive'."
! (let ((v (variable-at-point))
(enable-recursive-minibuffers t)
val)
(setq val (completing-read
--- 488,497 ----
(defun custom-variable-prompt ()
"Prompt for a custom variable, defaulting to the variable at point.
+ If that variable is an alias, the default is the actual custom variable
+ at the end of the chain of aliases.
Return a list suitable for use in `interactive'."
! (let ((v (indirect-variable (variable-at-point)))
(enable-recursive-minibuffers t)
val)
(setq val (completing-read
***************
*** 1021,1026 ****
--- 1023,1029 ----
(defun customize-option (symbol)
"Customize SYMBOL, which must be a user option variable."
(interactive (custom-variable-prompt))
+ (setq symbol (indirect-variable symbol))
(custom-buffer-create (list (list symbol 'custom-variable))
(format "*Customize Option: %s*"
(custom-unlispify-tag-name symbol))))
***************
*** 1033,1038 ****
--- 1036,1042 ----
"Customize SYMBOL, which must be a user option variable.
Show the buffer in another window, but don't select it."
(interactive (custom-variable-prompt))
+ (setq symbol (indirect-variable symbol))
(custom-buffer-create-other-window
(list (list symbol 'custom-variable))
(format "*Customize Option: %s*" (custom-unlispify-tag-name symbol))))
Diff finished. Mon Jul 4 20:24:04 2005
============================================================
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-07-05 1:42 ` Luc Teirlinck
@ 2005-07-05 16:12 ` Richard M. Stallman
2005-07-07 1:54 ` Luc Teirlinck
0 siblings, 1 reply; 47+ messages in thread
From: Richard M. Stallman @ 2005-07-05 16:12 UTC (permalink / raw
Cc: lekktu, emacs-devel
(defun custom-variable-prompt ()
"Prompt for a custom variable, defaulting to the variable at point.
+ If that variable is an alias, the default is the actual custom variable
+ at the end of the chain of aliases.
Return a list suitable for use in `interactive'."
! (let ((v (indirect-variable (variable-at-point)))
(enable-recursive-minibuffers t)
val)
The default that the user sees should be what's in the buffer.
Otherwise it will be mysterious. The conversion of aliases
to their real names should happen only on the user's input.
If you just leave this function unchanged and install the rest,
it should work. However, it would be good to make one additional
change: the same commands should display a message of the form
`%s' is an alias for `%s'
in the echo area.
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-07-05 16:12 ` Richard M. Stallman
@ 2005-07-07 1:54 ` Luc Teirlinck
2005-07-07 21:30 ` Richard M. Stallman
0 siblings, 1 reply; 47+ messages in thread
From: Luc Teirlinck @ 2005-07-07 1:54 UTC (permalink / raw
Cc: lekktu, emacs-devel
Richard Stallman wrote:
If you just leave this function unchanged and install the rest,
it should work. However, it would be good to make one additional
change: the same commands should display a message of the form
`%s' is an alias for `%s'
in the echo area.
What about the following new patch?
===File ~/cus-edit-diff=====================================
*** cus-edit.el 06 Jul 2005 17:24:52 -0500 1.226
--- cus-edit.el 06 Jul 2005 20:06:50 -0500
***************
*** 1021,1029 ****
(defun customize-option (symbol)
"Customize SYMBOL, which must be a user option variable."
(interactive (custom-variable-prompt))
! (custom-buffer-create (list (list symbol 'custom-variable))
! (format "*Customize Option: %s*"
! (custom-unlispify-tag-name symbol))))
;;;###autoload
(defalias 'customize-variable-other-window 'customize-option-other-window)
--- 1021,1032 ----
(defun customize-option (symbol)
"Customize SYMBOL, which must be a user option variable."
(interactive (custom-variable-prompt))
! (let ((basevar (indirect-variable symbol)))
! (custom-buffer-create (list (list basevar 'custom-variable))
! (format "*Customize Option: %s*"
! (custom-unlispify-tag-name basevar)))
! (unless (eq symbol basevar)
! (message "`%s' is an alias for `%s'" symbol basevar))))
;;;###autoload
(defalias 'customize-variable-other-window 'customize-option-other-window)
***************
*** 1033,1041 ****
"Customize SYMBOL, which must be a user option variable.
Show the buffer in another window, but don't select it."
(interactive (custom-variable-prompt))
! (custom-buffer-create-other-window
! (list (list symbol 'custom-variable))
! (format "*Customize Option: %s*" (custom-unlispify-tag-name symbol))))
(defvar customize-changed-options-previous-release "20.2"
"Version for `customize-changed-options' to refer back to by default.")
--- 1036,1047 ----
"Customize SYMBOL, which must be a user option variable.
Show the buffer in another window, but don't select it."
(interactive (custom-variable-prompt))
! (let ((basevar (indirect-variable symbol)))
! (custom-buffer-create-other-window
! (list (list basevar 'custom-variable))
! (format "*Customize Option: %s*" (custom-unlispify-tag-name basevar)))
! (unless (eq symbol basevar)
! (message "`%s' is an alias for `%s'" symbol basevar))))
(defvar customize-changed-options-previous-release "20.2"
"Version for `customize-changed-options' to refer back to by default.")
============================================================
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: Documentation not clear for the Lisp function set-variable
2005-07-07 1:54 ` Luc Teirlinck
@ 2005-07-07 21:30 ` Richard M. Stallman
0 siblings, 0 replies; 47+ messages in thread
From: Richard M. Stallman @ 2005-07-07 21:30 UTC (permalink / raw
Cc: lekktu, emacs-devel
If you just leave this function unchanged and install the rest,
it should work. However, it would be good to make one additional
change: the same commands should display a message of the form
`%s' is an alias for `%s'
in the echo area.
What about the following new patch?
It looks good. Thanks.
^ permalink raw reply [flat|nested] 47+ messages in thread
end of thread, other threads:[~2005-07-07 21:30 UTC | newest]
Thread overview: 47+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-19 11:14 Documentation not clear for the Lisp function set-variable Yoni Rabkin
2005-06-20 3:50 ` Richard Stallman
2005-06-20 8:21 ` Yoni Rabkin
2005-06-20 9:07 ` Juanma Barranquero
2005-06-21 2:00 ` Richard Stallman
2005-06-26 23:23 ` Juri Linkov
2005-06-27 13:04 ` Juanma Barranquero
2005-06-27 15:44 ` Juanma Barranquero
2005-06-27 16:09 ` Luc Teirlinck
2005-06-27 18:17 ` Juanma Barranquero
2005-06-27 18:45 ` Luc Teirlinck
2005-06-27 19:30 ` Juanma Barranquero
2005-06-28 18:47 ` Richard M. Stallman
2005-07-04 1:18 ` Luc Teirlinck
2005-07-04 16:48 ` Richard M. Stallman
2005-07-04 17:02 ` David Kastrup
2005-07-05 1:42 ` Luc Teirlinck
2005-07-05 16:12 ` Richard M. Stallman
2005-07-07 1:54 ` Luc Teirlinck
2005-07-07 21:30 ` Richard M. Stallman
2005-06-28 0:07 ` Juri Linkov
2005-06-28 8:32 ` Juanma Barranquero
2005-06-28 23:45 ` Juri Linkov
2005-06-29 9:14 ` Juanma Barranquero
2005-06-29 23:57 ` Juri Linkov
2005-06-30 8:16 ` Juanma Barranquero
2005-06-30 16:55 ` Luc Teirlinck
2005-06-30 19:34 ` Juanma Barranquero
2005-07-01 23:57 ` Juri Linkov
2005-07-02 4:11 ` Luc Teirlinck
2005-06-28 18:47 ` Richard M. Stallman
2005-06-29 2:32 ` Juanma Barranquero
2005-06-29 20:42 ` Richard M. Stallman
2005-06-27 18:39 ` Eli Zaretskii
2005-06-27 18:49 ` Luc Teirlinck
2005-06-27 21:38 ` Juanma Barranquero
2005-06-28 4:37 ` Eli Zaretskii
2005-06-28 8:33 ` Juanma Barranquero
2005-06-28 4:17 ` Richard M. Stallman
2005-06-28 9:17 ` Juanma Barranquero
2005-06-28 9:26 ` Juanma Barranquero
2005-06-28 16:09 ` Stefan Monnier
2005-06-28 16:19 ` Juanma Barranquero
2005-06-29 3:43 ` Stefan Monnier
2005-06-29 9:18 ` Juanma Barranquero
2005-06-29 3:59 ` Richard M. Stallman
2005-06-27 16:46 ` Richard M. Stallman
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).