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
|
173
|
32 ;; XEmacs: this code has been ported to C by Steve Baur. The
|
|
33 ;; implementations should be equivalent.
|
|
34
|
|
35
|
140
|
36 ;;; Code:
|
|
37
|
|
38 (eval-when-compile (require 'cl))
|
|
39
|
|
40 (provide (if (string-match "XEmacs" emacs-version) 'xemacs 'emacs))
|
|
41
|
|
42 (defvar featurep-emacs-version nil
|
|
43 "The version number of this Emacs, as a floating-point number.")
|
|
44
|
|
45 (defun featurep (fexp)
|
|
46 "Return non-nil if feature expression FEXP is true."
|
|
47 (typecase fexp
|
142
|
48 (symbol (and (memq fexp features) ;original definition
|
|
49 t))
|
140
|
50 (number (>= (or featurep-emacs-version
|
|
51 (setq featurep-emacs-version
|
|
52 (+ emacs-major-version
|
|
53 (/ emacs-minor-version 100.0))))
|
|
54 fexp))
|
|
55 (list (case (pop fexp)
|
|
56 (not (let ((negate (pop fexp)))
|
|
57 (if fexp
|
|
58 (signal 'invalid-read-syntax (list fexp))
|
|
59 (not (featurep negate)))))
|
|
60 (and (while (and fexp (featurep (car fexp)))
|
|
61 (pop fexp))
|
|
62 (null fexp))
|
|
63 (or (while (and fexp (not (featurep (car fexp))))
|
|
64 (pop fexp))
|
|
65 fexp)
|
|
66 (t (signal 'invalid-read-syntax (list fexp)))))
|
|
67 (t (signal 'invalid-read-syntax (list fexp)))))
|
|
68
|
|
69 ;;; featurep.el ends here
|
|
70
|