1 /* Mocklisp compatibility functions for GNU Emacs Lisp interpreter.
2 Copyright (C) 1985, 1986, 1995 Free Software Foundation, Inc.
4 This file is part of GNU Emacs.
6 GNU Emacs is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
22 /* Compatibility for mocklisp */
28 /* Now in lisp code ("macrocode...")
29 * DEFUN ("ml-defun", Fml_defun, Sml_defun, 0, UNEVALLED, 0,
30 * "Define mocklisp functions")
36 * while (!NILP (args))
39 * Ffset (Fcar (elt), Fcons (Qmocklisp, Fcdr (elt)));
46 DEFUN ("ml-if", Fml_if
, Sml_if
, 0, UNEVALLED
, 0, "Mocklisp version of `if'.")
50 register Lisp_Object val
;
57 val
= Feval (Fcar (args
));
59 if (NILP (args
)) break;
62 val
= Feval (Fcar (args
));
71 #if 0 /* Now converted to regular "while" by hairier conversion code. */
72 /**/DEFUN ("ml-while", Fml_while
, Sml_while
, 1, UNEVALLED
, 0, "while for mocklisp programs")
76 Lisp_Object test
, body
, tem
;
77 struct gcpro gcpro1
, gcpro2
;
83 while (tem
= Feval (test
), XINT (tem
))
94 /* This is the main entry point to mocklisp execution.
95 When eval sees a mocklisp function being called, it calls here
96 with the unevaluated argument list */
99 ml_apply (function
, args
)
100 Lisp_Object function
, args
;
102 register int count
= specpdl_ptr
- specpdl
;
103 register Lisp_Object val
;
105 specbind (Qmocklisp_arguments
, args
);
106 val
= Fprogn (Fcdr (function
));
107 return unbind_to (count
, val
);
110 DEFUN ("ml-nargs", Fml_nargs
, Sml_nargs
, 0, 0, 0,
111 "Number of arguments to currently executing mocklisp function.")
114 if (EQ (Vmocklisp_arguments
, Qinteractive
))
115 return make_number (0);
116 return Flength (Vmocklisp_arguments
);
119 DEFUN ("ml-arg", Fml_arg
, Sml_arg
, 1, 2, 0,
120 "Argument number N to currently executing mocklisp function.")
122 Lisp_Object n
, prompt
;
124 if (EQ (Vmocklisp_arguments
, Qinteractive
))
125 return Fread_string (prompt
, Qnil
, Qnil
, Qnil
, Qnil
);
127 XSETINT (n
, XINT (n
) - 1); /* Mocklisp likes to be origin-1 */
128 return Fcar (Fnthcdr (n
, Vmocklisp_arguments
));
131 DEFUN ("ml-interactive", Fml_interactive
, Sml_interactive
, 0, 0, 0,
132 "True if currently executing mocklisp function was called interactively.")
135 return (EQ (Vmocklisp_arguments
, Qinteractive
)) ? Qt
: Qnil
;
138 DEFUN ("ml-provide-prefix-argument", Fml_provide_prefix_argument
, Sml_provide_prefix_argument
,
140 "Evaluate second argument, using first argument as prefix arg value.")
146 Vcurrent_prefix_arg
= Feval (Fcar (args
));
148 return Feval (Fcar (Fcdr (args
)));
151 DEFUN ("ml-prefix-argument-loop", Fml_prefix_argument_loop
, Sml_prefix_argument_loop
,
157 register Lisp_Object tem
;
161 /* Set `arg' in case we call a built-in function that looks at it. Still are a few. */
162 if (NILP (Vcurrent_prefix_arg
))
166 tem
= Vcurrent_prefix_arg
;
169 if (EQ (tem
, Qminus
))
181 #if 0 /* Now in mlsupport.el */
183 DEFUN ("ml-substr", Fml_substr
, Sml_substr
, 3, 3, 0,
184 "Return a substring of STRING, starting at index FROM and of length LENGTH.\n\
185 If either FROM or LENGTH is negative, the length of STRING is added to it.")
187 Lisp_Object string
, from
, to
;
189 CHECK_STRING (string
, 0);
190 CHECK_NUMBER (from
, 1);
191 CHECK_NUMBER (to
, 2);
194 XSETINT (from
, XINT (from
) + XSTRING (string
)->size
);
196 XSETINT (to
, XINT (to
) + XSTRING (string
)->size
);
197 XSETINT (to
, XINT (to
) + XINT (from
));
198 return Fsubstring (string
, from
, to
);
201 DEFUN ("insert-string", Finsert_string
, Sinsert_string
, 0, MANY
, 0,
202 "Mocklisp-compatibility insert function.\n\
203 Like the function `insert' except that any argument that is a number\n\
204 is converted into a string by expressing it in decimal.")
210 register Lisp_Object tem
;
212 for (argnum
= 0; argnum
< nargs
; argnum
++)
217 tem
= Fnumber_to_string (tem
);
222 tem
= wrong_type_argument (Qstringp
, tem
);
234 Qmocklisp
= intern ("mocklisp");
235 staticpro (&Qmocklisp
);
237 /*defsubr (&Sml_defun);*/
239 /*defsubr (&Sml_while);*/
241 defsubr (&Sml_nargs
);
242 defsubr (&Sml_interactive
);
243 defsubr (&Sml_provide_prefix_argument
);
244 defsubr (&Sml_prefix_argument_loop
);
245 /*defsubr (&Sml_substr);*/
246 defsubr (&Sinsert_string
);