comparison lisp/prim/featurep.el @ 140:585fb297b004 r20-2b4

Import from CVS: tag r20-2b4
author cvs
date Mon, 13 Aug 2007 09:32:43 +0200
parents
children 1856695b1fa9
comparison
equal deleted inserted replaced
139:2b5203979d01 140:585fb297b004
1 ;;; featurep.el --- Support functions for reader conditionals
2
3 ;; Copyright 1997 Naggum Software
4
5 ;; Author: Erik Naggum <erik@naggum.no>
6 ;; Keywords: internal
7
8 ;; This file is not (yet) part of GNU Emacs, but distributed under the
9 ;; same conditions as GNU Emacs, and is useless without GNU Emacs.
10
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
15
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to
23 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
25
26 ;;; Commentary:
27
28 ;; The #+ and #- reader macros require support code to work properly until
29 ;; `featurep' is enhanced in the C code. This support code is written in
30 ;; Lisp to make it easier to experiment with the code.
31
32 ;;; Code:
33
34 (eval-when-compile (require 'cl))
35
36 (provide (if (string-match "XEmacs" emacs-version) 'xemacs 'emacs))
37
38 (defvar featurep-emacs-version nil
39 "The version number of this Emacs, as a floating-point number.")
40
41 (defun featurep (fexp)
42 "Return non-nil if feature expression FEXP is true."
43 (typecase fexp
44 (symbol (memq fexp features)) ;original definition
45 (number (>= (or featurep-emacs-version
46 (setq featurep-emacs-version
47 (+ emacs-major-version
48 (/ emacs-minor-version 100.0))))
49 fexp))
50 (list (case (pop fexp)
51 (not (let ((negate (pop fexp)))
52 (if fexp
53 (signal 'invalid-read-syntax (list fexp))
54 (not (featurep negate)))))
55 (and (while (and fexp (featurep (car fexp)))
56 (pop fexp))
57 (null fexp))
58 (or (while (and fexp (not (featurep (car fexp))))
59 (pop fexp))
60 fexp)
61 (t (signal 'invalid-read-syntax (list fexp)))))
62 (t (signal 'invalid-read-syntax (list fexp)))))
63
64 ;;; featurep.el ends here
65