Remove defining user variables via * in docstring.

* lisp/apropos.el (apropos-variable):
* lisp/files-x.el (read-file-local-variable):
* lisp/simple.el (set-variable):
* lisp/woman.el (woman-mini-help):
* lisp/emacs-lisp/byte-opt.el (side-effect-free-fns): Callers changed.

* lisp/custom.el (custom-variable-p): Return nil for non-symbol
arguments instead of signaling an error.
(user-variable-p): Obsolete alias for custom-variable-p.

* lisp/erc/erc.el (erc-cmd-SET): Call custom-variable-p instead of
user-variable-p.

* src/callint.c (Finteractive, Fcall_interactively):
* src/minibuf.c (Fread_variable): Callers changed.

* src/eval.c (Fuser_variable_p, user_variable_p_eh)
(lisp_indirect_variable): Functions deleted.
(Fdefvar): Caller changed.

* doc/lispref/commands.texi (Interactive Codes):
* doc/lispref/help.texi (Accessing Documentation):
* doc/lispref/minibuf.texi (High-Level Completion): Callers changed.

* doc/lispref/customize.texi (Variable Definitions): Remove user-variable-p.
This commit is contained in:
Chong Yidong 2012-04-09 20:36:01 +08:00
parent 9e40dda4c6
commit b4d3bc10dc
20 changed files with 68 additions and 100 deletions

View file

@ -1,3 +1,11 @@
2012-04-09 Chong Yidong <cyd@gnu.org>
* customize.texi (Variable Definitions): Remove user-variable-p.
* commands.texi (Interactive Codes):
* help.texi (Accessing Documentation):
* minibuf.texi (High-Level Completion): Callers changed.
2012-04-06 Chong Yidong <cyd@gnu.org>
* minibuf.texi (Programmed Completion): Document metadata method.

View file

@ -482,7 +482,7 @@ discarded, @samp{U} provides @code{nil} as the argument. No I/O.
@item v
A variable declared to be a user option (i.e., satisfying the
predicate @code{user-variable-p}). This reads the variable using
predicate @code{custom-variable-p}). This reads the variable using
@code{read-variable}. @xref{Definition of read-variable}. Existing,
Completion, Prompt.

View file

@ -462,14 +462,6 @@ meaning it was declared with @code{defcustom}), or an alias for
another customizable variable.
@end defun
@defun user-variable-p arg
This function is like @code{custom-variable-p}, except it also returns
@code{t} if the first character of the variable's documentation string
is the character @samp{*}. That is an obsolete way of indicating a
user option, so for most purposes you may consider
@code{user-variable-p} as equivalent to @code{custom-variable-p}.
@end defun
@node Customization Types
@section Customization Types

View file

@ -218,7 +218,7 @@ in the `*Help*' buffer."
@group
(princ
(format "%s\t%s\n%s\n\n" s
(if (user-variable-p s)
(if (custom-variable-p s)
"Option " "Variable")
@end group
@group

View file

@ -1313,17 +1313,17 @@ If the user then types @kbd{fill-p @key{RET}}, @code{read-variable}
returns @code{fill-prefix}.
In general, @code{read-variable} is similar to @code{read-command},
but uses the predicate @code{user-variable-p} instead of
but uses the predicate @code{custom-variable-p} instead of
@code{commandp}:
@cindex @code{user-variable-p} example
@cindex @code{custom-variable-p} example
@example
@group
(read-variable @var{prompt})
@equiv{}
(intern
(completing-read @var{prompt} obarray
'user-variable-p t nil))
'custom-variable-p t nil))
@end group
@end example
@end defun

View file

@ -43,6 +43,13 @@ been adding them there, put them somewhere else, eg site-lisp.
* New Modes and Packages in Emacs 24.2
* Incompatible Lisp Changes in Emacs 24.2
+++
** Docstrings starting with `*' no longer indicate user options.
Only variables defined using `defcustom' are considered user options.
The function `user-variable-p' is now an obsolete alias for
`custom-variable-p'.
* Lisp changes in Emacs 24.2

View file

@ -1,3 +1,15 @@
2012-04-09 Chong Yidong <cyd@gnu.org>
* custom.el (custom-variable-p): Return nil for non-symbol
arguments instead of signaling an error.
(user-variable-p): Obsolete alias for custom-variable-p.
* apropos.el (apropos-variable):
* files-x.el (read-file-local-variable):
* simple.el (set-variable):
* woman.el (woman-mini-help):
* emacs-lisp/byte-opt.el (side-effect-free-fns): Callers changed.
2012-04-09 Glenn Morris <rgm@gnu.org>
* startup.el (normal-top-level): Don't look for leim-list.el

View file

@ -466,7 +466,7 @@ normal variables."
#'(lambda (symbol)
(and (boundp symbol)
(get symbol 'variable-documentation)))
'user-variable-p)))
'custom-variable-p)))
;; For auld lang syne:
;;;###autoload

View file

@ -599,15 +599,17 @@ If NOSET is non-nil, don't bother autoloading LOAD when setting the variable."
(put symbol 'custom-autoload (if noset 'noset t))
(custom-add-load symbol load))
;; This test is also in the C code of `user-variable-p'.
(defun custom-variable-p (variable)
"Return non-nil if VARIABLE is a customizable variable.
A customizable variable is either (i) a variable whose property
list contains a non-nil `standard-value' or `custom-autoload'
property, or (ii) an alias for another customizable variable."
(setq variable (indirect-variable variable))
(or (get variable 'standard-value)
(get variable 'custom-autoload)))
(when (symbolp variable)
(setq variable (indirect-variable variable))
(or (get variable 'standard-value)
(get variable 'custom-autoload))))
(define-obsolete-function-alias 'user-variable-p 'custom-variable-p "24.2")
(defun custom-note-var-changed (variable)
"Inform Custom that VARIABLE has been set (changed).

View file

@ -1237,7 +1237,7 @@
string-to-multibyte
tan truncate
unibyte-char-to-multibyte upcase user-full-name
user-login-name user-original-login-name user-variable-p
user-login-name user-original-login-name custom-variable-p
vconcat
window-buffer window-dedicated-p window-edges window-height
window-hscroll window-minibuffer-p window-width

View file

@ -1,3 +1,8 @@
2012-04-09 Chong Yidong <cyd@gnu.org>
* erc.el (erc-cmd-SET): Call custom-variable-p instead of
user-variable-p.
2012-02-08 Glenn Morris <rgm@gnu.org>
* erc-backend.el (erc-coding-system-precedence):

View file

@ -2616,7 +2616,7 @@ VALUE is computed by evaluating the rest of LINE in Lisp."
(if (consp val)
(concat "\n" (pp-to-string val))
(format " %S\n" val)))))
(apropos-internal "^erc-" 'user-variable-p))))
(apropos-internal "^erc-" 'custom-variable-p))))
(current-buffer)) t)
(t nil)))
(defalias 'erc-cmd-VAR 'erc-cmd-SET)

View file

@ -49,7 +49,7 @@ Intended to be used in the `interactive' spec of
(format "%s: " prompt))
obarray
(lambda (sym)
(or (user-variable-p sym)
(or (custom-variable-p sym)
(get sym 'safe-local-variable)
(memq sym '(mode eval coding unibyte))))
nil nil nil default nil))

View file

@ -5983,7 +5983,7 @@ in the definition is used to check that VALUE is valid.
With a prefix argument, set VARIABLE to VALUE buffer-locally."
(interactive
(let* ((default-var (variable-at-point))
(var (if (user-variable-p default-var)
(var (if (custom-variable-p default-var)
(read-variable (format "Set variable (default %s): " default-var)
default-var)
(read-variable "Set variable: ")))

View file

@ -456,7 +456,7 @@ automatically, and you are prompted to fill in the variable parts.")))
;; obarray
;; (lambda (symbol)
;; (or (eq symbol 'eval)
;; (user-variable-p symbol)))
;; (custom-variable-p symbol)))
;; t)
;; comment-start str ": "
;; (read-from-minibuffer "Expression: " nil read-expression-map nil

View file

@ -1987,7 +1987,7 @@ Optional argument REDRAW, if non-nil, forces mode line to be updated."
(lambda (symbol)
(and
(or (commandp symbol)
(user-variable-p symbol))
(custom-variable-p symbol))
(not (get symbol 'apropos-inhibit))))))
;; Find documentation strings:
(let ((p apropos-accumulator)
@ -1999,7 +1999,7 @@ Optional argument REDRAW, if non-nil, forces mode line to be updated."
(if (setq doc (documentation symbol t))
(substring doc 0 (string-match "\n" doc))
"(not documented)"))
(if (user-variable-p symbol) ; 3. variable doc
(if (custom-variable-p symbol) ; 3. variable doc
(if (setq doc (documentation-property
symbol 'variable-documentation t))
(substring doc 0 (string-match "\n" doc))))))

View file

@ -1,3 +1,12 @@
2012-04-09 Chong Yidong <cyd@gnu.org>
* eval.c (Fuser_variable_p, user_variable_p_eh)
(lisp_indirect_variable): Functions deleted.
(Fdefvar): Caller changed.
* callint.c (Finteractive, Fcall_interactively):
* minibuf.c (Fread_variable): Callers changed.
2012-04-09 Eli Zaretskii <eliz@gnu.org>
* xdisp.c (set_cursor_from_row): If the display string appears in

View file

@ -97,7 +97,7 @@ r -- Region: point and mark as 2 numeric args, smallest first. Does no I/O.
s -- Any string. Does not inherit the current input method.
S -- Any symbol.
U -- Mouse up event discarded by a previous k or K argument.
v -- Variable name: symbol that is user-variable-p.
v -- Variable name: symbol that is `custom-variable-p'.
x -- Lisp expression read but not evaluated.
X -- Lisp expression read and evaluated.
z -- Coding system.
@ -748,7 +748,7 @@ invoke it. If KEYS is omitted or nil, the return value of
break;
case 'v': /* Variable name: symbol that is
user-variable-p. */
custom-variable-p. */
args[i] = Fread_variable (callint_message, Qnil);
visargs[i] = last_minibuf_string;
break;

View file

@ -808,8 +808,6 @@ The optional argument DOCSTRING is a documentation string for the
variable.
To define a user option, use `defcustom' instead of `defvar'.
The function `user-variable-p' also identifies a variable as a user
option if its DOCSTRING starts with *, but this behavior is obsolete.
usage: (defvar SYMBOL &optional INITVALUE DOCSTRING) */)
(Lisp_Object args)
{
@ -923,71 +921,6 @@ usage: (defconst SYMBOL INITVALUE [DOCSTRING]) */)
return sym;
}
/* Error handler used in Fuser_variable_p. */
static Lisp_Object
user_variable_p_eh (Lisp_Object ignore)
{
return Qnil;
}
static Lisp_Object
lisp_indirect_variable (Lisp_Object sym)
{
struct Lisp_Symbol *s = indirect_variable (XSYMBOL (sym));
XSETSYMBOL (sym, s);
return sym;
}
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.)
This function returns t if (i) the first character of its
documentation is `*', or (ii) it is customizable (its property list
contains a non-nil value of `standard-value' or `custom-autoload'), or
\(iii) it is an alias for a user variable.
But condition (i) is considered obsolete, so for most purposes this is
equivalent to `custom-variable-p'. */)
(Lisp_Object variable)
{
Lisp_Object documentation;
if (!SYMBOLP (variable))
return Qnil;
/* If indirect and there's an alias loop, don't check anything else. */
if (XSYMBOL (variable)->redirect == SYMBOL_VARALIAS
&& NILP (internal_condition_case_1 (lisp_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)->redirect == SYMBOL_VARALIAS))
return Qnil;
/* An indirect variable? Let's follow the chain. */
XSETSYMBOL (variable, SYMBOL_ALIAS (XSYMBOL (variable)));
}
}
DEFUN ("let*", FletX, SletX, 1, UNEVALLED, 0,
doc: /* Bind variables according to VARLIST then eval BODY.
@ -3789,7 +3722,6 @@ alist of active lexical bindings. */);
defsubr (&Sdefvar);
defsubr (&Sdefvaralias);
defsubr (&Sdefconst);
defsubr (&Suser_variable_p);
defsubr (&Slet);
defsubr (&SletX);
defsubr (&Swhile);

View file

@ -72,7 +72,7 @@ Lisp_Object Qcompletion_ignore_case;
static Lisp_Object Qminibuffer_completion_table;
static Lisp_Object Qminibuffer_completion_predicate;
static Lisp_Object Qminibuffer_completion_confirm;
static Lisp_Object Quser_variable_p;
static Lisp_Object Qcustom_variable_p;
static Lisp_Object Qminibuffer_default;
@ -1094,10 +1094,11 @@ Prompt with PROMPT. */)
#endif /* NOTDEF */
DEFUN ("read-variable", Fread_variable, Sread_variable, 1, 2, 0,
doc: /* Read the name of a user variable and return it as a symbol.
doc: /* Read the name of a user option and return it as a symbol.
Prompt with PROMPT. By default, return DEFAULT-VALUE or its first element
if it is a list.
A user variable is one for which `user-variable-p' returns non-nil. */)
A user option, or customizable variable, is one for which
`custom-variable-p' returns non-nil. */)
(Lisp_Object prompt, Lisp_Object default_value)
{
Lisp_Object name, default_string;
@ -1110,7 +1111,7 @@ A user variable is one for which `user-variable-p' returns non-nil. */)
default_string = default_value;
name = Fcompleting_read (prompt, Vobarray,
Quser_variable_p, Qt,
Qcustom_variable_p, Qt,
Qnil, Qnil, default_string, Qnil);
if (NILP (name))
return name;
@ -1975,11 +1976,11 @@ syms_of_minibuf (void)
staticpro (&last_minibuf_string);
last_minibuf_string = Qnil;
DEFSYM (Quser_variable_p, "user-variable-p");
DEFSYM (Qminibuffer_history, "minibuffer-history");
DEFSYM (Qbuffer_name_history, "buffer-name-history");
Fset (Qbuffer_name_history, Qnil);
DEFSYM (Qcustom_variable_p, "custom-variable-p");
DEFSYM (Qminibuffer_setup_hook, "minibuffer-setup-hook");
DEFSYM (Qminibuffer_exit_hook, "minibuffer-exit-hook");
DEFSYM (Qhistory_length, "history-length");