diff options
| author | Juanma Barranquero | 2005-06-29 02:08:32 +0000 |
|---|---|---|
| committer | Juanma Barranquero | 2005-06-29 02:08:32 +0000 |
| commit | 606cdb8902753c80cc588fb4b0f7016d67e809d1 (patch) | |
| tree | cca849b0fb32c4d87a73a20af7b8d4f3bd64e6e5 /src/eval.c | |
| parent | 27484eb05f32d6f0fe1691c2e078a63042afd3da (diff) | |
| download | emacs-606cdb8902753c80cc588fb4b0f7016d67e809d1.tar.gz emacs-606cdb8902753c80cc588fb4b0f7016d67e809d1.zip | |
(user_variable_p_eh): New function.
(Fuser_variable_p): Use it. Clarify docstring.
Return t for aliases of user options, nil for alias loops.
Diffstat (limited to 'src/eval.c')
| -rw-r--r-- | src/eval.c | 68 |
1 files changed, 47 insertions, 21 deletions
diff --git a/src/eval.c b/src/eval.c index 26ed0ef53c4..17e9f7f4360 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -889,12 +889,24 @@ usage: (defconst SYMBOL INITVALUE [DOCSTRING]) */) | |||
| 889 | return sym; | 889 | return sym; |
| 890 | } | 890 | } |
| 891 | 891 | ||
| 892 | /* Error handler used in Fuser_variable_p. */ | ||
| 893 | static Lisp_Object | ||
| 894 | user_variable_p_eh (ignore) | ||
| 895 | Lisp_Object ignore; | ||
| 896 | { | ||
| 897 | return Qnil; | ||
| 898 | } | ||
| 899 | |||
| 892 | DEFUN ("user-variable-p", Fuser_variable_p, Suser_variable_p, 1, 1, 0, | 900 | DEFUN ("user-variable-p", Fuser_variable_p, Suser_variable_p, 1, 1, 0, |
| 893 | doc: /* Returns t if VARIABLE is intended to be set and modified by users. | 901 | doc: /* Return t if VARIABLE is intended to be set and modified by users. |
| 894 | \(The alternative is a variable used internally in a Lisp program.) | 902 | \(The alternative is a variable used internally in a Lisp program.) |
| 895 | Determined by whether the first character of the documentation | 903 | A variable is a user variable if |
| 896 | for the variable is `*' or if the variable is customizable (has a non-nil | 904 | \(1) the first character of its documentation is `*', or |
| 897 | value of `standard-value' or of `custom-autoload' on its property list). */) | 905 | \(2) it is customizable (its property list contains a non-nil value |
| 906 | of `standard-value' or `custom-autoload'), or | ||
| 907 | \(3) it is an alias for another user variable. | ||
| 908 | Return nil if VARIABLE is an alias and there is a loop in the | ||
| 909 | chain of symbols. */) | ||
| 898 | (variable) | 910 | (variable) |
| 899 | Lisp_Object variable; | 911 | Lisp_Object variable; |
| 900 | { | 912 | { |
| @@ -903,23 +915,37 @@ value of `standard-value' or of `custom-autoload' on its property list). */) | |||
| 903 | if (!SYMBOLP (variable)) | 915 | if (!SYMBOLP (variable)) |
| 904 | return Qnil; | 916 | return Qnil; |
| 905 | 917 | ||
| 906 | documentation = Fget (variable, Qvariable_documentation); | 918 | /* If indirect and there's an alias loop, don't check anything else. */ |
| 907 | if (INTEGERP (documentation) && XINT (documentation) < 0) | 919 | if (XSYMBOL (variable)->indirect_variable |
| 908 | return Qt; | 920 | && NILP (internal_condition_case_1 (indirect_variable, variable, |
| 909 | if (STRINGP (documentation) | 921 | Qt, user_variable_p_eh))) |
| 910 | && ((unsigned char) SREF (documentation, 0) == '*')) | 922 | return Qnil; |
| 911 | return Qt; | 923 | |
| 912 | /* If it is (STRING . INTEGER), a negative integer means a user variable. */ | 924 | while (1) |
| 913 | if (CONSP (documentation) | 925 | { |
| 914 | && STRINGP (XCAR (documentation)) | 926 | documentation = Fget (variable, Qvariable_documentation); |
| 915 | && INTEGERP (XCDR (documentation)) | 927 | if (INTEGERP (documentation) && XINT (documentation) < 0) |
| 916 | && XINT (XCDR (documentation)) < 0) | 928 | return Qt; |
| 917 | return Qt; | 929 | if (STRINGP (documentation) |
| 918 | /* Customizable? See `custom-variable-p'. */ | 930 | && ((unsigned char) SREF (documentation, 0) == '*')) |
| 919 | if ((!NILP (Fget (variable, intern ("standard-value")))) | 931 | return Qt; |
| 920 | || (!NILP (Fget (variable, intern ("custom-autoload"))))) | 932 | /* If it is (STRING . INTEGER), a negative integer means a user variable. */ |
| 921 | return Qt; | 933 | if (CONSP (documentation) |
| 922 | return Qnil; | 934 | && STRINGP (XCAR (documentation)) |
| 935 | && INTEGERP (XCDR (documentation)) | ||
| 936 | && XINT (XCDR (documentation)) < 0) | ||
| 937 | return Qt; | ||
| 938 | /* Customizable? See `custom-variable-p'. */ | ||
| 939 | if ((!NILP (Fget (variable, intern ("standard-value")))) | ||
| 940 | || (!NILP (Fget (variable, intern ("custom-autoload"))))) | ||
| 941 | return Qt; | ||
| 942 | |||
| 943 | if (!XSYMBOL (variable)->indirect_variable) | ||
| 944 | return Qnil; | ||
| 945 | |||
| 946 | /* An indirect variable? Let's follow the chain. */ | ||
| 947 | variable = XSYMBOL (variable)->value; | ||
| 948 | } | ||
| 923 | } | 949 | } |
| 924 | 950 | ||
| 925 | DEFUN ("let*", FletX, SletX, 1, UNEVALLED, 0, | 951 | DEFUN ("let*", FletX, SletX, 1, UNEVALLED, 0, |