From b4d3bc10dc84f6b01a2b6b215d0e489555aa6edd Mon Sep 17 00:00:00 2001 From: Chong Yidong Date: Mon, 9 Apr 2012 20:36:01 +0800 Subject: [PATCH] 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. --- doc/lispref/ChangeLog | 8 +++++ doc/lispref/commands.texi | 2 +- doc/lispref/customize.texi | 8 ----- doc/lispref/help.texi | 2 +- doc/lispref/minibuf.texi | 6 ++-- etc/NEWS | 7 ++++ lisp/ChangeLog | 12 +++++++ lisp/apropos.el | 2 +- lisp/custom.el | 10 +++--- lisp/emacs-lisp/byte-opt.el | 2 +- lisp/erc/ChangeLog | 5 +++ lisp/erc/erc.el | 2 +- lisp/files-x.el | 2 +- lisp/simple.el | 2 +- lisp/skeleton.el | 2 +- lisp/woman.el | 4 +-- src/ChangeLog | 9 +++++ src/callint.c | 4 +-- src/eval.c | 68 ------------------------------------- src/minibuf.c | 11 +++--- 20 files changed, 68 insertions(+), 100 deletions(-) diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index afd6700ef6..81558bbd24 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog @@ -1,3 +1,11 @@ +2012-04-09 Chong Yidong + + * 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 * minibuf.texi (Programmed Completion): Document metadata method. diff --git a/doc/lispref/commands.texi b/doc/lispref/commands.texi index 617f050f49..95039d36b7 100644 --- a/doc/lispref/commands.texi +++ b/doc/lispref/commands.texi @@ -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. diff --git a/doc/lispref/customize.texi b/doc/lispref/customize.texi index 4c3adee0db..d86aea24fb 100644 --- a/doc/lispref/customize.texi +++ b/doc/lispref/customize.texi @@ -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 diff --git a/doc/lispref/help.texi b/doc/lispref/help.texi index 537514d7fb..c703e7810f 100644 --- a/doc/lispref/help.texi +++ b/doc/lispref/help.texi @@ -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 diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi index 4e11bc30d4..437a2daa8e 100644 --- a/doc/lispref/minibuf.texi +++ b/doc/lispref/minibuf.texi @@ -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 diff --git a/etc/NEWS b/etc/NEWS index 16357f3cfd..a1ef62c0bd 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -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 diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ed4470b998..8c3093aa2c 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,15 @@ +2012-04-09 Chong Yidong + + * 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 * startup.el (normal-top-level): Don't look for leim-list.el diff --git a/lisp/apropos.el b/lisp/apropos.el index 423656c21f..56b27e9b9b 100644 --- a/lisp/apropos.el +++ b/lisp/apropos.el @@ -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 diff --git a/lisp/custom.el b/lisp/custom.el index bffd30bff2..d8909f8be9 100644 --- a/lisp/custom.el +++ b/lisp/custom.el @@ -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). diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el index 78ac29d89d..3b324a0965 100644 --- a/lisp/emacs-lisp/byte-opt.el +++ b/lisp/emacs-lisp/byte-opt.el @@ -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 diff --git a/lisp/erc/ChangeLog b/lisp/erc/ChangeLog index af853c4e23..34aa015d7a 100644 --- a/lisp/erc/ChangeLog +++ b/lisp/erc/ChangeLog @@ -1,3 +1,8 @@ +2012-04-09 Chong Yidong + + * erc.el (erc-cmd-SET): Call custom-variable-p instead of + user-variable-p. + 2012-02-08 Glenn Morris * erc-backend.el (erc-coding-system-precedence): diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index b95d42b154..63777fb389 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -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) diff --git a/lisp/files-x.el b/lisp/files-x.el index b4a04401a7..e28e2ba83e 100644 --- a/lisp/files-x.el +++ b/lisp/files-x.el @@ -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)) diff --git a/lisp/simple.el b/lisp/simple.el index 8b04534455..64356ce8aa 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -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: "))) diff --git a/lisp/skeleton.el b/lisp/skeleton.el index 0f28d32293..5838915b1f 100644 --- a/lisp/skeleton.el +++ b/lisp/skeleton.el @@ -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 diff --git a/lisp/woman.el b/lisp/woman.el index 4ecf7c8891..c76399a96e 100644 --- a/lisp/woman.el +++ b/lisp/woman.el @@ -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)))))) diff --git a/src/ChangeLog b/src/ChangeLog index c1fcfcf243..7c3dd115c5 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2012-04-09 Chong Yidong + + * 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 * xdisp.c (set_cursor_from_row): If the display string appears in diff --git a/src/callint.c b/src/callint.c index e09210f1bb..96e2e10b9d 100644 --- a/src/callint.c +++ b/src/callint.c @@ -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; diff --git a/src/eval.c b/src/eval.c index 4a3f5083b3..1a6501a2b6 100644 --- a/src/eval.c +++ b/src/eval.c @@ -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); diff --git a/src/minibuf.c b/src/minibuf.c index a9bdf06b73..05f9419ba3 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -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"); -- 2.20.1