Mercurial > hg > xemacs-beta
comparison src/fns.c @ 209:41ff10fd062f r20-4b3
Import from CVS: tag r20-4b3
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:04:58 +0200 |
parents | e45d5e7c476e |
children | 78478c60bfcd |
comparison
equal
deleted
inserted
replaced
208:f427b8ec4379 | 209:41ff10fd062f |
---|---|
3349 DEFUN ("featurep", Ffeaturep, 1, 1, 0, /* | 3349 DEFUN ("featurep", Ffeaturep, 1, 1, 0, /* |
3350 Return non-nil if feature FEXP is present in this Emacs. | 3350 Return non-nil if feature FEXP is present in this Emacs. |
3351 Use this to conditionalize execution of lisp code based on the | 3351 Use this to conditionalize execution of lisp code based on the |
3352 presence or absence of emacs or environment extensions. | 3352 presence or absence of emacs or environment extensions. |
3353 FEXP can be a symbol, a number, or a list. | 3353 FEXP can be a symbol, a number, or a list. |
3354 If a symbol, it will be looked up in the `features' variable, and | 3354 If it is a symbol, that symbol is looked up in the `features' variable, |
3355 non-nil will be returned if it is found. | 3355 and non-nil will be returned if found. |
3356 If FEXP is a number, the function will return non-nil if this Emacs | 3356 If it is a number, the function will return non-nil if this Emacs |
3357 has an equal or greater version number than FEXP. | 3357 has an equal or greater version number than FEXP. |
3358 If FEXP is a list whose car is the symbol `and', it will return | 3358 If it is a list whose car is the symbol `and', it will return |
3359 non-nil if all the features in its cdr are non-nil. | 3359 non-nil if all the features in its cdr are non-nil. |
3360 If FEXP is a list whose car is the symbol `or', it will return non-nil | 3360 If it is a list whose car is the symbol `or', it will return non-nil |
3361 if any of the features in its cdr are non-nil. | 3361 if any of the features in its cdr are non-nil. |
3362 If FEXP is a list whose car is the symbol `not', it will return | 3362 If it is a list whose car is the symbol `not', it will return |
3363 non-nil if the feature is not present. | 3363 non-nil if the feature is not present. |
3364 | |
3365 Examples: | |
3366 | |
3367 (featurep 'xemacs) | |
3368 => ; Non-nil on XEmacs. | |
3369 | |
3370 (featurep '(and xemacs gnus)) | |
3371 => ; Non-nil on XEmacs with Gnus loaded. | |
3372 | |
3373 (featurep '(or tty-frames (and emacs 19.30))) | |
3374 => ; Non-nil if this Emacs supports TTY frames. | |
3375 | |
3376 (featurep '(or (and xemacs 19.15) (and emacs 19.34))) | |
3377 => ; Non-nil on XEmacs 19.15 and later, or FSF Emacs 19.34 and later. | |
3378 | |
3379 NOTE: The advanced arguments of this function (anything other than a | |
3380 symbol) are not yet supported by FSF Emacs. If you feel they are useful | |
3381 for supporting multiple Emacs variants, lobby Richard Stallman at | |
3382 <bug-gnu-emacs@prep.ai.mit.edu>. | |
3364 */ | 3383 */ |
3365 (fexp)) | 3384 (fexp)) |
3366 { | 3385 { |
3367 #ifndef FEATUREP_SYNTAX | 3386 #ifndef FEATUREP_SYNTAX |
3368 CHECK_SYMBOL (fexp); | 3387 CHECK_SYMBOL (fexp); |
3369 return NILP (Fmemq (fexp, Vfeatures)) ? Qnil : Qt; | 3388 return NILP (Fmemq (fexp, Vfeatures)) ? Qnil : Qt; |
3370 #else /* FEATUREP_SYNTAX */ | 3389 #else /* FEATUREP_SYNTAX */ |
3371 extern Lisp_Object Vemacs_major_version, Vemacs_minor_version; | 3390 extern Lisp_Object Vemacs_major_version, Vemacs_minor_version; |
3391 extern Lisp_Object Qfeaturep; | |
3372 static double featurep_emacs_version; | 3392 static double featurep_emacs_version; |
3373 | 3393 |
3374 /* Brute force translation from Erik Naggum's lisp function. */ | 3394 /* Brute force translation from Erik Naggum's lisp function. */ |
3375 if (SYMBOLP(fexp)) | 3395 if (SYMBOLP(fexp)) |
3376 { | 3396 { |
3398 Lisp_Object negate; | 3418 Lisp_Object negate; |
3399 | 3419 |
3400 tem = XCDR (fexp); | 3420 tem = XCDR (fexp); |
3401 negate = Fcar (tem); | 3421 negate = Fcar (tem); |
3402 if (!NILP (tem)) | 3422 if (!NILP (tem)) |
3403 return NILP (Ffeaturep (negate)) ? Qt : Qnil; | 3423 return NILP (call1 (Qfeaturep, negate)) ? Qt : Qnil; |
3404 else | 3424 else |
3405 return Fsignal (Qinvalid_read_syntax, list1 (tem)); | 3425 return Fsignal (Qinvalid_read_syntax, list1 (tem)); |
3406 } | 3426 } |
3407 else if (EQ(tem, Qand)) | 3427 else if (EQ(tem, Qand)) |
3408 { | 3428 { |
3409 tem = XCDR(fexp); | 3429 tem = XCDR(fexp); |
3410 /* Use Fcar/Fcdr for error-checking. */ | 3430 /* Use Fcar/Fcdr for error-checking. */ |
3411 while (!NILP (tem) && !NILP (Ffeaturep (Fcar (tem)))) | 3431 while (!NILP (tem) && !NILP (call1 (Qfeaturep, Fcar (tem)))) |
3412 { | 3432 { |
3413 tem = Fcdr (tem); | 3433 tem = Fcdr (tem); |
3414 } | 3434 } |
3415 return NILP(tem) ? Qt : Qnil; | 3435 return NILP(tem) ? Qt : Qnil; |
3416 } | 3436 } |
3417 else if (EQ(tem, Qor)) | 3437 else if (EQ(tem, Qor)) |
3418 { | 3438 { |
3419 tem = XCDR (fexp); | 3439 tem = XCDR (fexp); |
3420 /* Use Fcar/Fcdr for error-checking. */ | 3440 /* Use Fcar/Fcdr for error-checking. */ |
3421 while (!NILP (tem) && NILP (Ffeaturep (Fcar (tem)))) | 3441 while (!NILP (tem) && NILP (call1 (Qfeaturep, Fcar (tem)))) |
3422 { | 3442 { |
3423 tem = Fcdr (tem); | 3443 tem = Fcdr (tem); |
3424 } | 3444 } |
3425 return NILP(tem) ? Qnil : Qt; | 3445 return NILP(tem) ? Qnil : Qt; |
3426 } | 3446 } |