summaryrefslogtreecommitdiff
path: root/test/src
diff options
context:
space:
mode:
authorPhilipp Stephani <phst@google.com>2020-09-13 20:21:41 +0200
committerPhilipp Stephani <phst@google.com>2020-09-13 20:26:47 +0200
commitda0e75e7410226d7fd6d760f0ebe8a04d815506d (patch)
tree1c850a5c13e3af18b7ca8cfe1b785d51300d9dde /test/src
parent3eb4e0db5ce247f8396daac3156087fbb7aefbd4 (diff)
downloademacs-da0e75e7410226d7fd6d760f0ebe8a04d815506d.tar.gz
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/src')
-rw-r--r--test/src/emacs-module-tests.el32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/src/emacs-module-tests.el b/test/src/emacs-module-tests.el
index 096c6b30574..1eebb418cf3 100644
--- a/test/src/emacs-module-tests.el
+++ b/test/src/emacs-module-tests.el
@@ -468,4 +468,36 @@ See Bug#36226."
(should (equal (buffer-string) "data from thread")))
(delete-process process)))))
+(ert-deftest module/interactive/return-t ()
+ (should (functionp (symbol-function #'mod-test-return-t)))
+ (should (module-function-p (symbol-function #'mod-test-return-t)))
+ (should-not (commandp #'mod-test-return-t))
+ (should-not (commandp (symbol-function #'mod-test-return-t)))
+ (should-not (interactive-form #'mod-test-return-t))
+ (should-not (interactive-form (symbol-function #'mod-test-return-t)))
+ (should-error (call-interactively #'mod-test-return-t)
+ :type 'wrong-type-argument))
+
+(ert-deftest module/interactive/return-t-int ()
+ (should (functionp (symbol-function #'mod-test-return-t-int)))
+ (should (module-function-p (symbol-function #'mod-test-return-t-int)))
+ (should (commandp #'mod-test-return-t-int))
+ (should (commandp (symbol-function #'mod-test-return-t-int)))
+ (should (equal (interactive-form #'mod-test-return-t-int) '(interactive)))
+ (should (equal (interactive-form (symbol-function #'mod-test-return-t-int))
+ '(interactive)))
+ (should (eq (mod-test-return-t-int) t))
+ (should (eq (call-interactively #'mod-test-return-t-int) t)))
+
+(ert-deftest module/interactive/identity ()
+ (should (functionp (symbol-function #'mod-test-identity)))
+ (should (module-function-p (symbol-function #'mod-test-identity)))
+ (should (commandp #'mod-test-identity))
+ (should (commandp (symbol-function #'mod-test-identity)))
+ (should (equal (interactive-form #'mod-test-identity) '(interactive "i")))
+ (should (equal (interactive-form (symbol-function #'mod-test-identity))
+ '(interactive "i")))
+ (should (eq (mod-test-identity 123) 123))
+ (should-not (call-interactively #'mod-test-identity)))
+
;;; emacs-module-tests.el ends here