comparison src/fns.c @ 50:ee648375d8d6 r19-16b91

Import from CVS: tag r19-16b91
author cvs
date Mon, 13 Aug 2007 08:56:41 +0200
parents 56c54cf7c5b6
children 131b0175ea99
comparison
equal deleted inserted replaced
49:b46643e427ac 50:ee648375d8d6
3029 return ret; 3029 return ret;
3030 } 3030 }
3031 3031
3032 3032
3033 Lisp_Object Vfeatures; 3033 Lisp_Object Vfeatures;
3034 extern Lisp_Object Vemacs_major_version, Vemacs_minor_version;
3034 3035
3035 DEFUN ("featurep", Ffeaturep, 1, 1, 0, /* 3036 DEFUN ("featurep", Ffeaturep, 1, 1, 0, /*
3036 Return t if FEATURE is present in this Emacs. 3037 Return non-nil if feature expression FEXP is true.
3037 Use this to conditionalize execution of lisp code based on the 3038 */
3038 presence or absence of emacs or environment extensions. 3039 (fexp))
3039 Use `provide' to declare that a feature is available. 3040 {
3040 This function looks at the value of the variable `features'. 3041 static double featurep_emacs_version;
3041 */ 3042
3042 (feature)) 3043 /* Brute force translation from Erik Naggum's lisp function. */
3043 { 3044 if (SYMBOLP(fexp))
3044 CHECK_SYMBOL (feature); 3045 {
3045 return NILP (Fmemq (feature, Vfeatures)) ? Qnil : Qt; 3046 /* Original definition */
3047 return NILP (Fmemq (fexp, Vfeatures)) ? Qnil : Qt;
3048 }
3049 else if (INTP(fexp) || FLOATP(fexp))
3050 {
3051 double d = extract_float(fexp);
3052
3053 if (featurep_emacs_version == 0.0)
3054 {
3055 featurep_emacs_version = XINT (Vemacs_major_version) +
3056 (XINT (Vemacs_minor_version) / 100.0);
3057 }
3058 return featurep_emacs_version >= d ? Qt : Qnil;
3059 }
3060 else if (CONSP(fexp))
3061 {
3062 Lisp_Object tem;
3063
3064 tem = XCAR(fexp);
3065 if (EQ(tem, Qnot))
3066 {
3067 Lisp_Object negate = XCDR(fexp);
3068
3069 if (!NILP(XCDR(fexp)))
3070 {
3071 return Fsignal(Qinvalid_read_syntax, list1(XCDR(fexp)));
3072 }
3073 else
3074 {
3075 return NILP(Ffeaturep(negate)) ? Qt : Qnil;
3076 }
3077 }
3078 else if (EQ(tem, Qand))
3079 {
3080 tem = XCDR(fexp);
3081 while (!NILP(tem) && !NILP(Ffeaturep(XCAR(tem))))
3082 {
3083 tem = XCDR(tem);
3084 }
3085 return NILP(tem) ? Qt : Qnil;
3086 }
3087 else if (EQ(tem, Qor))
3088 {
3089 tem = XCDR(fexp);
3090 while (!NILP(tem) && NILP(Ffeaturep(XCAR(tem))))
3091 {
3092 tem = XCDR(tem);
3093 }
3094 return NILP(tem) ? Qnil : Qt;
3095 }
3096 else
3097 {
3098 return Fsignal(Qinvalid_read_syntax, list1(XCDR(fexp)));
3099 }
3100 }
3101 else
3102 {
3103 return Fsignal(Qinvalid_read_syntax, list1 (fexp));
3104 }
3046 } 3105 }
3047 3106
3048 DEFUN ("provide", Fprovide, 1, 1, 0, /* 3107 DEFUN ("provide", Fprovide, 1, 1, 0, /*
3049 Announce that FEATURE is a feature of the current Emacs. 3108 Announce that FEATURE is a feature of the current Emacs.
3050 This function updates the value of the variable `features'. 3109 This function updates the value of the variable `features'.