annotate src/mocklisp.c @ 22:8fc7fe29b841 r19-15b94

Import from CVS: tag r19-15b94
author cvs
date Mon, 13 Aug 2007 08:50:29 +0200
parents 859a2309aef8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* Mocklisp compatibility functions for XEmacs Lisp interpreter.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1985, 1986, 1992, 1993, 1995 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 under the terms of the GNU General Public License as published by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 Free Software Foundation; either version 2, or (at your option) any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 along with XEmacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 Boston, MA 02111-1307, USA. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 /* Synched up with: FSF 19.30. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 /* Compatibility for mocklisp */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 #include <config.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 #ifdef MOCKLISP_SUPPORT /* whole file */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 #include "lisp.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 #include "buffer.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 Lisp_Object Qmocklisp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 Lisp_Object Qmocklisp_arguments;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 Lisp_Object Vmocklisp_arguments;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 #if 0 /* Now in lisp code ("macrocode...") */
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
38 xxDEFUN ("ml-defun", ml_defun, 0, UNEVALLED, 0 /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 Define mocklisp functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 */ )
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
41 (Lisp_Object args)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 Lisp_Object elt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 while (!NILP (args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 elt = Fcar (args);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 Ffset (Fcar (elt), Fcons (Qmocklisp, Fcdr (elt)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 args = Fcdr (args);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 #endif /* 0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
56 DEFUN ("ml-if", Fml_if, 0, UNEVALLED, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 Mocklisp version of `if'.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
58 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
59 (args))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 Lisp_Object val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 struct gcpro gcpro1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 GCPRO1 (args);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 while (!NILP (args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 val = Feval (Fcar (args));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 args = Fcdr (args);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 if (NILP (args)) break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 if (XINT (val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 val = Feval (Fcar (args));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 args = Fcdr (args);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 return val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 #if 0 /* Now converted to regular "while" by hairier conversion code. */
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
83 xxDEFUN ("ml-while", ml_while, 1, UNEVALLED, 0 /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 while for mocklisp programs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 */ )
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
86 (Lisp_Object args)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 Lisp_Object test, body, tem;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 struct gcpro gcpro1, gcpro2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 GCPRO2 (test, body);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 test = Fcar (args);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 body = Fcdr (args);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 while (tem = Feval (test), XINT (tem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 QUIT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 Fprogn (body);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 #endif /* 0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 /* This is the main entry point to mocklisp execution.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 When eval sees a mocklisp function being called, it calls here
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 with the unevaluated argument list */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 ml_apply (Lisp_Object function, Lisp_Object args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 int speccount = specpdl_depth ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 Lisp_Object val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 specbind (Qmocklisp_arguments, args);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 val = Fprogn (Fcdr (function));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 return unbind_to (speccount, val);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 #if 0 /* now in lisp code */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 xxDEFUN ("ml-nargs", Fml_nargs, Sml_nargs, 0, 0, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 Number of arguments to currently executing mocklisp function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 if (EQ (Vmocklisp_arguments, Qinteractive))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 return make_int (0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 return Flength (Vmocklisp_arguments);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 /* now in lisp code */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 xxDEFUN ("ml-arg", Fml_arg, Sml_arg, 1, 2, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 Argument number N to currently executing mocklisp function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (n, prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 Lisp_Object n, prompt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 if (EQ (Vmocklisp_arguments, Qinteractive))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 return call1 (Qread_from_minibuffer, prompt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 CHECK_INT (n);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 XSETINT (n, XINT (n) - 1); /* Mocklisp likes to be origin-1 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 return Fcar (Fnthcdr (n, Vmocklisp_arguments));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 /* now in lisp code */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 xxDEFUN ("ml-interactive", Fml_interactive, Sml_interactive, 0, 0, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 True if currently executing mocklisp function was called interactively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 return (EQ (Vmocklisp_arguments, Qinteractive)) ? Qt : Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 #endif /* 0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 /* ??? Isn't this the same as `provide-prefix-arg' from mlsupport.el? */
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
163 DEFUN ("ml-provide-prefix-argument", Fml_provide_prefix_argument, 2, UNEVALLED, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 Evaluate second argument, using first argument as prefix arg value.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
165 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
166 (args))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 struct gcpro gcpro1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 GCPRO1 (args);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 Vcurrent_prefix_arg = Feval (Fcar (args));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 return Feval (Fcar (Fcdr (args)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
176 DEFUN ("ml-prefix-argument-loop", Fml_prefix_argument_loop, 0, UNEVALLED, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
178 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
179 (args))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 Lisp_Object tem;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 struct gcpro gcpro1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 /* Set `arg' in case we call a built-in function that looks at it. Still are a few. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 if (NILP (Vcurrent_prefix_arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 i = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 tem = Vcurrent_prefix_arg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 if (CONSP (tem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 tem = Fcar (tem);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 if (EQ (tem, Qminus))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 i = -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 else i = XINT (tem);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 GCPRO1 (args);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 while (i-- > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 Fprogn (args);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 /* now in lisp code */
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
209 DEFUN ("ml-substr", Fml_substr, 3, 3, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 Return a substring of STRING, starting at index FROM and of length LENGTH.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 If either FROM or LENGTH is negative, the length of STRING is added to it.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
212 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
213 (string, from, to))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 CHECK_STRING (string);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 CHECK_INT (from);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 CHECK_INT (to);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 if (XINT (from) < 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 XSETINT (from, XINT (from) + string_char_length (XSTRING (string)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 if (XINT (to) < 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 XSETINT (to, XINT (to) + string_char_length (XSTRING (string)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 XSETINT (to, XINT (to) + XINT (from));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 return Fsubstring (string, from, to);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 /* now in lisp code */
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
229 DEFUN ("insert-string", Finsert_string, 0, MANY, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 Mocklisp-compatibility insert function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 Like the function `insert' except that any argument that is a number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 is converted into a string by expressing it in decimal.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
233 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
234 (int nargs, Lisp_Object *args))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 int argnum;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 Lisp_Object tem;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 for (argnum = 0; argnum < nargs; argnum++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 tem = args[argnum];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 retry:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 if (INTP (tem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 tem = Fnumber_to_string (tem);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 if (STRINGP (tem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 buffer_insert1 (current_buffer, tem);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 tem = wrong_type_argument (Qstringp, tem);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 goto retry;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 #endif /* 0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 /* initialization */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 syms_of_mocklisp (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 defsymbol (&Qmocklisp, "mocklisp");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 defsymbol (&Qmocklisp_arguments, "mocklisp-arguments");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
269 /*DEFSUBR (Fml_defun);*/
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
270 DEFSUBR (Fml_if);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
271 /*DEFSUBR (Fml_while);*/
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
272 /*DEFSUBR (Fml_nargs);*/
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
273 /*DEFSUBR (Fml_arg);*/
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
274 /*DEFSUBR (Fml_interactive);*/
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
275 DEFSUBR (Fml_provide_prefix_argument);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
276 DEFSUBR (Fml_prefix_argument_loop);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
277 /*DEFSUBR (Fml_substr);*/
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
278 /*DEFSUBR (Finsert_string);*/
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 vars_of_mocklisp (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 DEFVAR_LISP ("mocklisp-arguments", &Vmocklisp_arguments /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 While in a mocklisp function, the list of its unevaluated args.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 Vmocklisp_arguments = Qt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 #endif /* MOCKLISP_SUPPORT */