140
|
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
|
142
|
44 (symbol (and (memq fexp features) ;original definition
|
|
45 t))
|
140
|
46 (number (>= (or featurep-emacs-version
|
|
47 (setq featurep-emacs-version
|
|
48 (+ emacs-major-version
|
|
49 (/ emacs-minor-version 100.0))))
|
|
50 fexp))
|
|
51 (list (case (pop fexp)
|
|
52 (not (let ((negate (pop fexp)))
|
|
53 (if fexp
|
|
54 (signal 'invalid-read-syntax (list fexp))
|
|
55 (not (featurep negate)))))
|
|
56 (and (while (and fexp (featurep (car fexp)))
|
|
57 (pop fexp))
|
|
58 (null fexp))
|
|
59 (or (while (and fexp (not (featurep (car fexp))))
|
|
60 (pop fexp))
|
|
61 fexp)
|
|
62 (t (signal 'invalid-read-syntax (list fexp)))))
|
|
63 (t (signal 'invalid-read-syntax (list fexp)))))
|
|
64
|
|
65 ;;; featurep.el ends here
|
|
66
|