diff options
| author | Philipp Stephani | 2019-01-02 22:04:56 +0100 |
|---|---|---|
| committer | Philipp Stephani | 2019-02-24 22:43:07 +0100 |
| commit | 72ec233f2a1b8a6a9574e61588d0467caf41755c (patch) | |
| tree | 725add4413feb9cb7789576294099096e63d3044 /src/emacs-module.c | |
| parent | 5653b76d0bacf1edfc3d962c0bb991344cd80f6f (diff) | |
| download | emacs-72ec233f2a1b8a6a9574e61588d0467caf41755c.tar.gz emacs-72ec233f2a1b8a6a9574e61588d0467caf41755c.zip | |
Ignore pending_signals when checking for quits.
pending_signals is often set if no quit is pending. This results in
bugs in module code if the module returns but no quit is actually
pending.
As a better alternative, add a new process_input environment function
for Emacs 27. That function processes signals (like maybe_quit).
* configure.ac: Add module snippet for Emacs 27.
* src/module-env-27.h: New file.
* src/emacs-module.h.in: Add process_input function to environment
interface.
* src/emacs-module.c (module_should_quit): Use QUITP macro to check
whether the caller should quit.
(module_process_input): New function.
(initialize_environment): Use it.
* src/eval.c: Remove obsolete comment.
* test/data/emacs-module/mod-test.c (signal_wrong_type_argument)
(signal_errno): New helper functions.
(Fmod_test_sleep_until): New test module function.
* test/src/emacs-module-tests.el (mod-test-sleep-until): New unit
test.
* doc/lispref/internals.texi (Module Misc): Document process_input.
Diffstat (limited to 'src/emacs-module.c')
| -rw-r--r-- | src/emacs-module.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/emacs-module.c b/src/emacs-module.c index cbab0234201..b70d6cea812 100644 --- a/src/emacs-module.c +++ b/src/emacs-module.c | |||
| @@ -671,13 +671,21 @@ module_vec_size (emacs_env *env, emacs_value vec) | |||
| 671 | return ASIZE (lvec); | 671 | return ASIZE (lvec); |
| 672 | } | 672 | } |
| 673 | 673 | ||
| 674 | /* This function should return true if and only if maybe_quit would do | 674 | /* This function should return true if and only if maybe_quit would |
| 675 | anything. */ | 675 | quit. */ |
| 676 | static bool | 676 | static bool |
| 677 | module_should_quit (emacs_env *env) | 677 | module_should_quit (emacs_env *env) |
| 678 | { | 678 | { |
| 679 | MODULE_FUNCTION_BEGIN_NO_CATCH (false); | 679 | MODULE_FUNCTION_BEGIN_NO_CATCH (false); |
| 680 | return (! NILP (Vquit_flag) && NILP (Vinhibit_quit)) || pending_signals; | 680 | return QUITP; |
| 681 | } | ||
| 682 | |||
| 683 | static enum emacs_process_input_result | ||
| 684 | module_process_input (emacs_env *env) | ||
| 685 | { | ||
| 686 | MODULE_FUNCTION_BEGIN (emacs_process_input_quit); | ||
| 687 | maybe_quit (); | ||
| 688 | return emacs_process_input_continue; | ||
| 681 | } | 689 | } |
| 682 | 690 | ||
| 683 | 691 | ||
| @@ -1082,6 +1090,7 @@ initialize_environment (emacs_env *env, struct emacs_env_private *priv) | |||
| 1082 | env->vec_get = module_vec_get; | 1090 | env->vec_get = module_vec_get; |
| 1083 | env->vec_size = module_vec_size; | 1091 | env->vec_size = module_vec_size; |
| 1084 | env->should_quit = module_should_quit; | 1092 | env->should_quit = module_should_quit; |
| 1093 | env->process_input = module_process_input; | ||
| 1085 | Vmodule_environments = Fcons (make_mint_ptr (env), Vmodule_environments); | 1094 | Vmodule_environments = Fcons (make_mint_ptr (env), Vmodule_environments); |
| 1086 | return env; | 1095 | return env; |
| 1087 | } | 1096 | } |