aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/emacs-module.c15
-rw-r--r--src/emacs-module.h3
-rw-r--r--src/eval.c5
3 files changed, 22 insertions, 1 deletions
diff --git a/src/emacs-module.c b/src/emacs-module.c
index f2efc83d257..e6a109b1962 100644
--- a/src/emacs-module.c
+++ b/src/emacs-module.c
@@ -28,6 +28,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
28#include "lisp.h" 28#include "lisp.h"
29#include "dynlib.h" 29#include "dynlib.h"
30#include "coding.h" 30#include "coding.h"
31#include "keyboard.h"
31#include "syssignal.h" 32#include "syssignal.h"
32 33
33#include <intprops.h> 34#include <intprops.h>
@@ -612,6 +613,15 @@ module_vec_size (emacs_env *env, emacs_value vec)
612 return ASIZE (lvec); 613 return ASIZE (lvec);
613} 614}
614 615
616/* This function should return true if and only if maybe_quit would do
617 anything. */
618static bool
619module_should_quit (emacs_env *env)
620{
621 MODULE_FUNCTION_BEGIN_NO_CATCH (false);
622 return (! NILP (Vquit_flag) && NILP (Vinhibit_quit)) || pending_signals;
623}
624
615 625
616/* Subroutines. */ 626/* Subroutines. */
617 627
@@ -687,6 +697,10 @@ funcall_module (Lisp_Object function, ptrdiff_t nargs, Lisp_Object *arglist)
687 697
688 eassert (&priv == pub.private_members); 698 eassert (&priv == pub.private_members);
689 699
700 /* Process the quit flag first, so that quitting doesn't get
701 overridden by other non-local exits. */
702 maybe_quit ();
703
690 switch (priv.pending_non_local_exit) 704 switch (priv.pending_non_local_exit)
691 { 705 {
692 case emacs_funcall_exit_return: 706 case emacs_funcall_exit_return:
@@ -916,6 +930,7 @@ initialize_environment (emacs_env *env, struct emacs_env_private *priv)
916 env->vec_set = module_vec_set; 930 env->vec_set = module_vec_set;
917 env->vec_get = module_vec_get; 931 env->vec_get = module_vec_get;
918 env->vec_size = module_vec_size; 932 env->vec_size = module_vec_size;
933 env->should_quit = module_should_quit;
919 Vmodule_environments = Fcons (make_save_ptr (env), Vmodule_environments); 934 Vmodule_environments = Fcons (make_save_ptr (env), Vmodule_environments);
920} 935}
921 936
diff --git a/src/emacs-module.h b/src/emacs-module.h
index d9eeeabec3f..b8bf2ed2d5f 100644
--- a/src/emacs-module.h
+++ b/src/emacs-module.h
@@ -185,6 +185,9 @@ struct emacs_env_25
185 emacs_value val); 185 emacs_value val);
186 186
187 ptrdiff_t (*vec_size) (emacs_env *env, emacs_value vec); 187 ptrdiff_t (*vec_size) (emacs_env *env, emacs_value vec);
188
189 /* Returns whether a quit is pending. */
190 bool (*should_quit) (emacs_env *env);
188}; 191};
189 192
190/* Every module should define a function as follows. */ 193/* Every module should define a function as follows. */
diff --git a/src/eval.c b/src/eval.c
index 8aa33a11282..ef961046bcf 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1474,7 +1474,10 @@ process_quit_flag (void)
1474 If quit-flag is set to `kill-emacs' the SIGINT handler has received 1474 If quit-flag is set to `kill-emacs' the SIGINT handler has received
1475 a request to exit Emacs when it is safe to do. 1475 a request to exit Emacs when it is safe to do.
1476 1476
1477 When not quitting, process any pending signals. */ 1477 When not quitting, process any pending signals.
1478
1479 If you change this function, also adapt module_should_quit in
1480 emacs-module.c. */
1478 1481
1479void 1482void
1480maybe_quit (void) 1483maybe_quit (void)