annotate lisp/prim/featurep.el @ 173:8eaf7971accc r20-3b13

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