Merge remote-tracking branch 'origin/master' into for-steve
[sxemacs] / lisp / very-early-lisp.el
1 ;;; very-early-lisp.el --- Lisp support always needed by temacs
2
3 ;; Copyright (C) 1998 by Free Software Foundation, Inc.
4
5 ;; Author: SL Baur <steve@xemacs.org>
6 ;;  Michael Sperber [Mr. Preprocessor] <sperber@Informatik.Uni-Tuebingen.De>
7 ;; Keywords: internal, dumped
8
9 ;; This file is part of SXEmacs.
10
11 ;; SXEmacs 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 3 of the License, or
14 ;; (at your option) any later version.
15
16 ;; SXEmacs 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 this program.  If not, see <http://www.gnu.org/licenses/>.
23
24 ;;; Synched up with: Not in FSF
25
26 ;;; Commentary:
27
28 ;; This file must be loaded by temacs if temacs is to process bytecode
29 ;; or dumped-lisp.el files.
30
31 ;;; Code:
32
33 ;;; Intended replacement for read-time Lisp reader macros #-, #+
34
35 (defmacro assemble-list (&rest components)
36   "Assemble a list from COMPONENTS.
37 This is a poor man's backquote:
38 COMPONENTS is a list, each element of which is macro-expanded.
39 Each macro-expanded element either has the form (SPLICE stuff),
40 in which case stuff must be a list which is spliced into the result.
41 Otherwise, the component becomes an element of the list."
42   (cons
43    'append
44    (mapcar #'(lambda (component)
45                (let ((component (macroexpand-internal component)))
46                  (if (and (consp component)
47                           (eq 'splice (car component)))
48                      (car (cdr component))
49                    (list 'list component))))
50            components)))
51
52 (defmacro when-feature (feature stuff)
53   "Insert STUFF as a list element if FEATURE is a loaded feature.
54 This is intended for use as a component of ASSEMBLE-LIST."
55   (list 'splice
56         (list 'if (list 'featurep (list 'quote feature))
57               (list 'list stuff)
58               '())))
59
60 (defmacro unless-feature (feature stuff)
61   "Insert STUFF as a list element if FEATURE is NOT a loaded feature.
62 This is intended for use as a component of ASSEMBLE-LIST."
63   (list 'splice
64         (list 'if (list 'featurep (list 'quote feature))
65               '()
66               (list 'list stuff))))
67
68 (provide 'very-early-lisp)
69
70 ;;; very-early-lisp.el ends here