all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juanma Barranquero <lekktu@gmail.com>
Cc: rms@gnu.org, emacs-devel@gnu.org
Subject: Re: Documentation not clear for the Lisp function set-variable
Date: Mon, 27 Jun 2005 17:44:49 +0200	[thread overview]
Message-ID: <f7ccd24b0506270844e12923d@mail.gmail.com> (raw)
In-Reply-To: <f7ccd24b050627060437f84b8b@mail.gmail.com>

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.  */

  reply	other threads:[~2005-06-27 15:44 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f7ccd24b0506270844e12923d@mail.gmail.com \
    --to=lekktu@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=rms@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.