diff options
| author | Philipp Stephani | 2017-06-04 19:34:22 +0200 |
|---|---|---|
| committer | Philipp Stephani | 2017-06-04 19:50:52 +0200 |
| commit | 66da3f4afa53e5c5cfab17ca03a13a0d65083ffb (patch) | |
| tree | b045d1aa2009d66502f83ef5d599d0d94294acb9 /src/emacs-module.c | |
| parent | d37201722e2151df1f6b6fa1e2f33b5f91e27e03 (diff) | |
| download | emacs-66da3f4afa53e5c5cfab17ca03a13a0d65083ffb.tar.gz emacs-66da3f4afa53e5c5cfab17ca03a13a0d65083ffb.zip | |
Support quitting in modules
The idea is that modules should call env->should_quit from time to
time and return as quickly as possible if it returns true.
* src/emacs-module.c (module_should_quit): New module function.
(initialize_environment): Use it.
(funcall_module): Process potential pending quit.
* src/eval.c (maybe_quit): Add reference to module_should_quit.
Diffstat (limited to 'src/emacs-module.c')
| -rw-r--r-- | src/emacs-module.c | 15 |
1 files changed, 15 insertions, 0 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. */ | ||
| 618 | static bool | ||
| 619 | module_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 | ||