annotate lisp/emacs-lisp/backquote.el @ 3759:036367460955

* sysdep.c [ultrix] (init_sys_modes): Don't set LLITOUT; it disables the meta key.
author Jim Blandy <jimb@redhat.com>
date Wed, 16 Jun 1993 20:02:58 +0000
parents 507f64624555
children de6afd5ec418
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2229
bd3c525fa6fc Added standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1330
diff changeset
1 ;;; backquote.el --- backquoting for Emacs Lisp macros
662
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
2
845
213978acbc1e entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 811
diff changeset
3 ;; Copyright (C) 1985 Free Software Foundation, Inc.
213978acbc1e entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 811
diff changeset
4
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
5 ;; Author: Dick King (king@kestrel).
811
e694e0879463 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 807
diff changeset
6 ;; Keywords: extensions
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
7
181
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
181
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; any later version.
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
24 ;;; Commentary:
181
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 2229
diff changeset
26 ;;; This is a rudimentary backquote package written by D. King,
181
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;;; king@kestrel, on 8/31/85. (` x) is a macro
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 ;;; that expands to a form that produces x. (` (a b ..)) is
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;;; a macro that expands into a form that produces a list of what a b
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;;; etc. would have produced. Any element can be of the form
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ;;; (, <form>) in which case the resulting form evaluates
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 ;;; <form> before putting it into place, or (,@ <form>), in which
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;;; case the evaluation of <form> is arranged for and each element
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 ;;; of the result (which must be a (possibly null) list) is inserted.
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;;; As an example, the immediately following macro push (v l) could
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;;; have been written
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 ;;; (defmacro push (v l)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;;; (` (setq (, l) (cons (,@ (list v l))))))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 ;;; although
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 ;;; (defmacro push (v l)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 ;;; (` (setq (, l) (cons (, v) (, l)))))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 ;;; is far more natural. The magic atoms ,
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 ;;; and ,@ are user-settable and list-valued. We recommend that
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 ;;; things never be removed from this list lest you break something
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 ;;; someone else wrote in the dim past that comes to be recompiled in
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 ;;; the distant future.
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 ;;; LIMITATIONS: tail consing is not handled correctly. Do not say
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 ;;; (` (a . (, b))) - say (` (a (,@ b)))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 ;;; which works even if b is not list-valued.
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 ;;; No attempt is made to handle vectors. (` [a (, b) c]) doesn't work.
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 ;;; Sorry, you must say things like
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 ;;; (` (a (,@ 'b))) to get (a . b) and
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 ;;; (` ((, ',) c)) to get (, c) - [(` (a , b)) will work but is a bad habit]
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 ;;; I haven't taught it the joys of nconc.
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 ;;; (` atom) dies. (` (, atom)) or anything else is okay.
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 ;;; BEWARE BEWARE BEWARE
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 ;;; inclusion of (,atom) rather than (, atom) or (,@atom) rather than
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 ;;; (,@ atom) will result in errors that will show up very late.
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 ;;; This is so crunchy that I am considering including a check for
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 ;;; this or changing the syntax to ... ,(<form>). RMS: opinion?
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
64 ;;; Code:
181
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 ;;; a raft of general-purpose macros follows. See the nearest
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 ;;; Commonlisp manual.
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 (defmacro bq-push (v l)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 "Pushes evaluated first form onto second unevaluated object
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 a list-value atom"
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 (list 'setq l (list 'cons v l)))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 (defmacro bq-caar (l)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 (list 'car (list 'car l)))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 (defmacro bq-cadr (l)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 (list 'car (list 'cdr l)))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 (defmacro bq-cdar (l)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 (list 'cdr (list 'car l)))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 ;;; These two advertised variables control what characters are used to
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 ;;; unquote things. I have included , and ,@ as the unquote and
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 ;;; splice operators, respectively, to give users of MIT CADR machine
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 2229
diff changeset
86 ;;; derivative machines a warm, cosy feeling.
181
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 (defconst backquote-unquote '(,)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 "*A list of all objects that stimulate unquoting in `. Memq test.")
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 (defconst backquote-splice '(,@)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 "*A list of all objects that stimulate splicing in `. Memq test.")
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 ;;; This is the interface
256
7e4c7ef44243 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 181
diff changeset
97 ;;;###autoload
181
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 (defmacro ` (form)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 "(` FORM) is a macro that expands to code to construct FORM.
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 Note that this is very slow in interpreted code, but fast if you compile.
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 FORM is one or more nested lists, which are `almost quoted':
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 They are copied recursively, with non-lists used unchanged in the copy.
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 (` a b) == (list 'a 'b) constructs a new list with two elements, `a' and `b'.
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 (` a (b c)) == (list 'a (list 'b 'c)) constructs two nested new lists.
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 However, certain special lists are not copied. They specify substitution.
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 Lists that look like (, EXP) are evaluated and the result is substituted.
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 (` a (, (+ x 5))) == (list 'a (+ x 5))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 Elements of the form (,@ EXP) are evaluated and then all the elements
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 of the result are substituted. This result must be a list; it may
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 be `nil'.
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 As an example, a simple macro `push' could be written:
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 (defmacro push (v l)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 (` (setq (, l) (cons (,@ (list v l))))))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 or as
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 (defmacro push (v l)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 (` (setq (, l) (cons (, v) (, l)))))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 LIMITATIONS: \"dotted lists\" are not allowed in FORM.
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 The ultimate cdr of each list scanned by ` must be `nil'.
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 \(This does not apply to constants inside expressions to be substituted.)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 Substitution elements are not allowed as the cdr
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 of a cons cell. For example, (` (A . (, B))) does not work.
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 Instead, write (` (A (,@ B))).
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 You cannot construct vectors, only lists. Vectors are treated as
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 constants.
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 BEWARE BEWARE BEWARE
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 Inclusion of (,ATOM) rather than (, ATOM)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 or of (,@ATOM) rather than (,@ ATOM)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 will result in errors that will show up very late."
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 (bq-make-maker form))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 ;;; We develop the method for building the desired list from
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 ;;; the end towards the beginning. The contract is that there be a
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 ;;; variable called state and a list called tailmaker, and that the form
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 ;;; (cons state tailmaker) deliver the goods. Exception - if the
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 ;;; state is quote the tailmaker is the form itself.
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 ;;; This function takes a form and returns what I will call a maker in
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 ;;; what follows. Evaluating the maker would produce the form,
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 ;;; properly evaluated according to , and ,@ rules.
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 ;;; I work backwards - it seemed a lot easier. The reason for this is
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 ;;; if I'm in some sort of a routine building a maker and I switch
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 ;;; gears, it seemed to me easier to jump into some other state and
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 ;;; glue what I've already done to the end, than to to prepare that
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 ;;; something and go back to put things together.
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 (defun bq-make-maker (form)
1234
9ca8c55f9ae5 Dox Fix
Christopher Zaborsky <rogue@erratum.com>
parents: 845
diff changeset
152 "Given argument FORM, a `mostly quoted' object, produces a maker.
181
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 See backquote.el for details"
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 (let ((tailmaker (quote nil)) (qc 0) (ec 0) (state nil))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 (mapcar 'bq-iterative-list-builder (reverse form))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 (and state
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 (cond ((eq state 'quote)
340
36bd3a9f20e2 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
158 (list state (if (equal form tailmaker) form tailmaker)))
181
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 ((= (length tailmaker) 1)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 (funcall (bq-cadr (assq state bq-singles)) tailmaker))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 (t (cons state tailmaker))))))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 ;;; There are exceptions - we wouldn't want to call append of one
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 ;;; argument, for example.
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 (defconst bq-singles '((quote bq-quotecar)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 (append car)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 (list bq-make-list)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 (cons bq-id)))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 (defun bq-id (x) x)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 (defun bq-quotecar (x) (list 'quote (car x)))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 (defun bq-make-list (x) (cons 'list x))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 ;;; fr debugging use only
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 ;(defun funcalll (a b) (funcall a b))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 ;(defun funcalll (a b) (debug nil 'enter state tailmaker a b)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 ; (let ((ans (funcall a b))) (debug nil 'leave state tailmaker)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 ; ans))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 ;;; Given a state/tailmaker pair that already knows how to make a
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 ;;; partial tail of the desired form, this function knows how to add
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 2229
diff changeset
184 ;;; yet another element to the burgeoning list. There are four cases;
181
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 ;;; the next item is an atom (which will certainly be quoted); a
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 ;;; (, xxx), which will be evaluated and put into the list at the top
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 ;;; level; a (,@ xxx), which will be evaluated and spliced in, or
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 ;;; some other list, in which case we first compute the form's maker,
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 ;;; and then we either launch into the quoted case if the maker's
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 ;;; top level function is quote, or into the comma case if it isn't.
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 ;;; The fourth case reduces to one of the other three, so here we have
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 ;;; a choice of three ways to build tailmaker, and cit turns out we
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 ;;; use five possible values of state (although someday I'll add
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 ;;; nconcto the possible values of state).
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 ;;; This maintains the invariant that (cons state tailmaker) is the
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 ;;; maker for the elements of the tail we've eaten so far.
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 (defun bq-iterative-list-builder (form)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 (cond ((atom form)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 (funcall (bq-cadr (assq state bq-quotefns)) form))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 ((memq (car form) backquote-unquote)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 (funcall (bq-cadr (assq state bq-evalfns)) (bq-cadr form)))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 ((memq (car form) backquote-splice)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 (funcall (bq-cadr (assq state bq-splicefns)) (bq-cadr form)))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 (t
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 (let ((newform (bq-make-maker form)))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 (if (and (listp newform) (eq (car newform) 'quote))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 (funcall (bq-cadr (assq state bq-quotefns)) (bq-cadr newform))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 (funcall (bq-cadr (assq state bq-evalfns)) newform))))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 ))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 ;;; We do a 2-d branch on the form of splicing and the old state.
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 ;;; Here's fifteen functions' names...
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 (defconst bq-splicefns '((nil bq-splicenil)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 (append bq-spliceappend)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 (list bq-splicelist)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 (quote bq-splicequote)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 (cons bq-splicecons)))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 (defconst bq-evalfns '((nil bq-evalnil)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 (append bq-evalappend)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 (list bq-evallist)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 (quote bq-evalquote)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 (cons bq-evalcons)))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 (defconst bq-quotefns '((nil bq-quotenil)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 (append bq-quoteappend)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 (list bq-quotelist)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 (quote bq-quotequote)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 (cons bq-quotecons)))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 ;;; The name of each function is
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 ;;; (concat 'bq- <type-of-element-addition> <old-state>)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 ;;; I'll comment the non-obvious ones before the definitions...
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 ;;; In what follows, uppercase letters and form will always be
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235 ;;; metavariables that don't need commas in backquotes, and I will
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 ;;; assume the existence of something like matches that takes a
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 ;;; backquote-like form and a value, binds metavariables and returns
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 ;;; t if the pattern match is successful, returns nil otherwise. I
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 ;;; will write such a goodie someday.
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 ;;; (setq tailmaker
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 ;;; (if (matches ((quote X) Y) tailmaker)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 ;;; (` ((quote (form X)) Y))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 ;;; (` ((list form (quote X)) Y))))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 ;;; (setq state 'append)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246 (defun bq-quotecons (form)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247 (if (and (listp (car tailmaker))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248 (eq (bq-caar tailmaker) 'quote))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 (setq tailmaker
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 (list (list 'quote (list form (bq-cadr (car tailmaker))))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 (bq-cadr tailmaker)))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 (setq tailmaker
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 (list (list 'list
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 (list 'quote form)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 (car tailmaker))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 (bq-cadr tailmaker))))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 (setq state 'append))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 (defun bq-quotequote (form)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 (bq-push form tailmaker))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 ;;; Could be improved to convert (list 'a 'b 'c .. 'w x)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 ;;; to (append '(a b c .. w) x)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 ;;; when there are enough elements
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 (defun bq-quotelist (form)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 (bq-push (list 'quote form) tailmaker))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268 ;;; (setq tailmaker
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 ;;; (if (matches ((quote X) (,@ Y)))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 ;;; (` ((quote (, (cons form X))) (,@ Y)))))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 (defun bq-quoteappend (form)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 (cond ((and (listp tailmaker)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 (listp (car tailmaker))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 (eq (bq-caar tailmaker) 'quote))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 (rplaca (bq-cdar tailmaker)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 (cons form (car (bq-cdar tailmaker)))))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277 (t (bq-push (list 'quote (list form)) tailmaker))))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 (defun bq-quotenil (form)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 (setq tailmaker (list form))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281 (setq state 'quote))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 ;;; (if (matches (X Y) tailmaker) ; it must
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 ;;; (` ((list form X) Y)))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 (defun bq-evalcons (form)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 (setq tailmaker
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 (list (list 'list form (car tailmaker))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288 (bq-cadr tailmaker)))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 (setq state 'append))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 ;;; (if (matches (X Y Z (,@ W)))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 ;;; (progn (setq state 'append)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 ;;; (` ((list form) (quote (X Y Z (,@ W))))))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 ;;; (progn (setq state 'list)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 ;;; (list form 'X 'Y .. ))) ; quote each one there is
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 (defun bq-evalquote (form)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 (cond ((< (length tailmaker) 3)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 (setq tailmaker
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 (cons form
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 (mapcar (function (lambda (x)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 (list 'quote x)))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 tailmaker)))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 (setq state 'list))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304 (t
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 (setq tailmaker
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306 (list (list 'list form)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307 (list 'quote tailmaker)))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308 (setq state 'append))))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310 (defun bq-evallist (form)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311 (bq-push form tailmaker))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313 ;;; (cond ((matches ((list (,@ X)) (,@ Y)))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314 ;;; (` ((list form (,@ X)) (,@ Y))))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315 ;;; ((matches (X))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316 ;;; (` (form (,@ X))) (setq state 'cons))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 ;;; ((matches ((,@ X)))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 ;;; (` (form (,@ X)))))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 (defun bq-evalappend (form)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320 (cond ((and (listp tailmaker)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321 (listp (car tailmaker))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322 (eq (bq-caar tailmaker) 'list))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323 (rplacd (car tailmaker)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 (cons form (bq-cdar tailmaker))))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 ((= (length tailmaker) 1)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326 (setq tailmaker (cons form tailmaker)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 state 'cons))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 (t (bq-push (list 'list form) tailmaker))))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 (defun bq-evalnil (form)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 (setq tailmaker (list form)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 state 'list))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 ;;; (if (matches (X Y)) ; it must
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 ;;; (progn (setq state 'append)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 ;;; (` (form (cons X Y))))) ; couldn't think of anything clever
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 (defun bq-splicecons (form)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338 (setq tailmaker
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 (list form
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 (list 'cons (car tailmaker) (bq-cadr tailmaker)))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341 state 'append))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343 (defun bq-splicequote (form)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344 (setq tailmaker (list form (list 'quote tailmaker))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
345 state 'append))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
346
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
347 (defun bq-splicelist (form)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
348 (setq tailmaker (list form (cons 'list tailmaker))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349 state 'append))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351 (defun bq-spliceappend (form)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352 (bq-push form tailmaker))
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354 (defun bq-splicenil (form)
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
355 (setq state 'append
a587d037d637 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
356 tailmaker (list form)))
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 340
diff changeset
357
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 340
diff changeset
358 (provide 'backquote)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 340
diff changeset
359
662
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
360 ;;; backquote.el ends here