diff options
| author | Gerd Moellmann | 2002-03-24 19:52:55 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2002-03-24 19:52:55 +0000 |
| commit | d6edd563f45e4ef68844146c802921a4282cb043 (patch) | |
| tree | 3abfd34520e67868a562deed9365854af7aa10c0 /src | |
| parent | 985b468607df1d1c9b703ffc3fb3f0ba91676905 (diff) | |
| download | emacs-d6edd563f45e4ef68844146c802921a4282cb043.tar.gz emacs-d6edd563f45e4ef68844146c802921a4282cb043.zip | |
(Qdeclare, Vmacro_declaration_function): New variables.
(Fdefmacro): Handle `(declare ...)'.
(syms_of_eval) <Qdeclare>: Initialize and staticpro.
(syms_of_eval) <Vmacro_declaration_function>: DEFVAR_LISP.
Diffstat (limited to 'src')
| -rw-r--r-- | src/eval.c | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/src/eval.c b/src/eval.c index c2ebfd46fe8..fc7a7f426bc 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -91,6 +91,7 @@ Lisp_Object Qautoload, Qmacro, Qexit, Qinteractive, Qcommandp, Qdefun; | |||
| 91 | Lisp_Object Qinhibit_quit, Vinhibit_quit, Vquit_flag; | 91 | Lisp_Object Qinhibit_quit, Vinhibit_quit, Vquit_flag; |
| 92 | Lisp_Object Qand_rest, Qand_optional; | 92 | Lisp_Object Qand_rest, Qand_optional; |
| 93 | Lisp_Object Qdebug_on_error; | 93 | Lisp_Object Qdebug_on_error; |
| 94 | Lisp_Object Qdeclare; | ||
| 94 | 95 | ||
| 95 | /* This holds either the symbol `run-hooks' or nil. | 96 | /* This holds either the symbol `run-hooks' or nil. |
| 96 | It is nil at an early stage of startup, and when Emacs | 97 | It is nil at an early stage of startup, and when Emacs |
| @@ -189,6 +190,11 @@ Lisp_Object Vsignaling_function; | |||
| 189 | 190 | ||
| 190 | int handling_signal; | 191 | int handling_signal; |
| 191 | 192 | ||
| 193 | /* Function to process declarations in defmacro forms. */ | ||
| 194 | |||
| 195 | Lisp_Object Vmacro_declaration_function; | ||
| 196 | |||
| 197 | |||
| 192 | static Lisp_Object funcall_lambda P_ ((Lisp_Object, int, Lisp_Object*)); | 198 | static Lisp_Object funcall_lambda P_ ((Lisp_Object, int, Lisp_Object*)); |
| 193 | 199 | ||
| 194 | void | 200 | void |
| @@ -651,9 +657,39 @@ usage: (defmacro NAME ARGLIST [DOCSTRING] BODY...) */) | |||
| 651 | { | 657 | { |
| 652 | register Lisp_Object fn_name; | 658 | register Lisp_Object fn_name; |
| 653 | register Lisp_Object defn; | 659 | register Lisp_Object defn; |
| 660 | Lisp_Object lambda_list, doc, tail; | ||
| 654 | 661 | ||
| 655 | fn_name = Fcar (args); | 662 | fn_name = Fcar (args); |
| 656 | defn = Fcons (Qmacro, Fcons (Qlambda, Fcdr (args))); | 663 | lambda_list = Fcar (Fcdr (args)); |
| 664 | tail = Fcdr (Fcdr (args)); | ||
| 665 | |||
| 666 | doc = Qnil; | ||
| 667 | if (STRINGP (Fcar (tail))) | ||
| 668 | { | ||
| 669 | doc = Fcar (tail); | ||
| 670 | tail = Fcdr (tail); | ||
| 671 | } | ||
| 672 | |||
| 673 | while (CONSP (Fcar (tail)) | ||
| 674 | && EQ (Fcar (Fcar (tail)), Qdeclare)) | ||
| 675 | { | ||
| 676 | if (!NILP (Vmacro_declaration_function)) | ||
| 677 | { | ||
| 678 | struct gcpro gcpro1; | ||
| 679 | GCPRO1 (args); | ||
| 680 | call2 (Vmacro_declaration_function, fn_name, Fcar (tail)); | ||
| 681 | UNGCPRO; | ||
| 682 | } | ||
| 683 | |||
| 684 | tail = Fcdr (tail); | ||
| 685 | } | ||
| 686 | |||
| 687 | if (NILP (doc)) | ||
| 688 | tail = Fcons (lambda_list, tail); | ||
| 689 | else | ||
| 690 | tail = Fcons (lambda_list, Fcons (doc, tail)); | ||
| 691 | defn = Fcons (Qmacro, Fcons (Qlambda, tail)); | ||
| 692 | |||
| 657 | if (!NILP (Vpurify_flag)) | 693 | if (!NILP (Vpurify_flag)) |
| 658 | defn = Fpurecopy (defn); | 694 | defn = Fpurecopy (defn); |
| 659 | Ffset (fn_name, defn); | 695 | Ffset (fn_name, defn); |
| @@ -3229,6 +3265,9 @@ before making `inhibit-quit' nil. */); | |||
| 3229 | Qmacro = intern ("macro"); | 3265 | Qmacro = intern ("macro"); |
| 3230 | staticpro (&Qmacro); | 3266 | staticpro (&Qmacro); |
| 3231 | 3267 | ||
| 3268 | Qdeclare = intern ("declare"); | ||
| 3269 | staticpro (&Qdeclare); | ||
| 3270 | |||
| 3232 | /* Note that the process handling also uses Qexit, but we don't want | 3271 | /* Note that the process handling also uses Qexit, but we don't want |
| 3233 | to staticpro it twice, so we just do it here. */ | 3272 | to staticpro it twice, so we just do it here. */ |
| 3234 | Qexit = intern ("exit"); | 3273 | Qexit = intern ("exit"); |
| @@ -3314,6 +3353,14 @@ Note that `debug-on-error', `debug-on-quit' and friends | |||
| 3314 | still determine whether to handle the particular condition. */); | 3353 | still determine whether to handle the particular condition. */); |
| 3315 | Vdebug_on_signal = Qnil; | 3354 | Vdebug_on_signal = Qnil; |
| 3316 | 3355 | ||
| 3356 | DEFVAR_LISP ("macro-declaration-function", &Vmacro_declaration_function, | ||
| 3357 | doc: /* Function to process declarations in a macro definition. | ||
| 3358 | The function will be called with two args MACRO and DECL. | ||
| 3359 | MACRO is the name of the macro being defined. | ||
| 3360 | DECL is a list `(declare ...)' containing the declarations. | ||
| 3361 | The value the function returns is not used. */); | ||
| 3362 | Vmacro_declaration_function = Qnil; | ||
| 3363 | |||
| 3317 | Vrun_hooks = intern ("run-hooks"); | 3364 | Vrun_hooks = intern ("run-hooks"); |
| 3318 | staticpro (&Vrun_hooks); | 3365 | staticpro (&Vrun_hooks); |
| 3319 | 3366 | ||