aboutsummaryrefslogtreecommitdiffstats
path: root/test/data
diff options
context:
space:
mode:
authorPhilipp Stephani2020-09-13 20:21:41 +0200
committerPhilipp Stephani2020-09-13 20:26:47 +0200
commitda0e75e7410226d7fd6d760f0ebe8a04d815506d (patch)
tree1c850a5c13e3af18b7ca8cfe1b785d51300d9dde /test/data
parent3eb4e0db5ce247f8396daac3156087fbb7aefbd4 (diff)
downloademacs-da0e75e7410226d7fd6d760f0ebe8a04d815506d.tar.gz
emacs-da0e75e7410226d7fd6d760f0ebe8a04d815506d.zip
Add facility to make module functions interactive (Bug#23486).
* src/module-env-28.h: Add field for 'make_interactive' function. * src/emacs-module.c (Lisp_Module_Function): Add new field holding the interactive form. (allocate_module_function): Adapt to structure layout change. (module_make_interactive, module_function_interactive_form): New functions. (initialize_environment): Use them. * src/eval.c (Fcommandp): * src/data.c (Finteractive_form): Also handle interactive module functions. * test/data/emacs-module/mod-test.c (Fmod_test_identity): New test function. (emacs_module_init): Create two interactive module test functions. * test/src/emacs-module-tests.el (module/interactive/return-t) (module/interactive/return-t-int, module/interactive/identity): New unit tests. * doc/lispref/internals.texi (Module Functions): Document new function. Rework paragraph about wrapping module functions, as the example no longer applies. * etc/NEWS: Document new facility.
Diffstat (limited to 'test/data')
-rw-r--r--test/data/emacs-module/mod-test.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/data/emacs-module/mod-test.c b/test/data/emacs-module/mod-test.c
index 37186fcc4d1..da298d4e398 100644
--- a/test/data/emacs-module/mod-test.c
+++ b/test/data/emacs-module/mod-test.c
@@ -673,6 +673,14 @@ Fmod_test_async_pipe (emacs_env *env, ptrdiff_t nargs, emacs_value *args,
673 return env->intern (env, "nil"); 673 return env->intern (env, "nil");
674} 674}
675 675
676static emacs_value
677Fmod_test_identity (emacs_env *env, ptrdiff_t nargs, emacs_value *args,
678 void *data)
679{
680 assert (nargs == 1);
681 return args[0];
682}
683
676/* Lisp utilities for easier readability (simple wrappers). */ 684/* Lisp utilities for easier readability (simple wrappers). */
677 685
678/* Provide FEATURE to Emacs. */ 686/* Provide FEATURE to Emacs. */
@@ -764,6 +772,19 @@ emacs_module_init (struct emacs_runtime *ert)
764 772
765#undef DEFUN 773#undef DEFUN
766 774
775 emacs_value constant_fn
776 = env->make_function (env, 0, 0, Fmod_test_return_t, NULL, NULL);
777 env->make_interactive (env, constant_fn, env->intern (env, "nil"));
778 bind_function (env, "mod-test-return-t-int", constant_fn);
779
780 emacs_value identity_fn
781 = env->make_function (env, 1, 1, Fmod_test_identity, NULL, NULL);
782 const char *interactive_spec = "i";
783 env->make_interactive (env, identity_fn,
784 env->make_string (env, interactive_spec,
785 strlen (interactive_spec)));
786 bind_function (env, "mod-test-identity", identity_fn);
787
767 provide (env, "mod-test"); 788 provide (env, "mod-test");
768 return 0; 789 return 0;
769} 790}