From 0592dff5c872bd5fc26e3e1204b1425d39f926c6 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Thu, 17 Sep 2009 23:48:34 +0200 Subject: [PATCH] Allow access to the minibuffer only to a thread at time. --- src/fns.c | 16 ++++++++++++++++ src/minibuf.c | 4 ++++ src/thread.h | 2 ++ 3 files changed, 22 insertions(+) diff --git a/src/fns.c b/src/fns.c index 7b4f3e7a549..4282ce34468 100644 --- a/src/fns.c +++ b/src/fns.c @@ -78,6 +78,8 @@ static int internal_equal P_ ((Lisp_Object , Lisp_Object, int, int)); extern long get_random (); extern void seed_random P_ ((long)); +static Lisp_Object Fyes_or_no1 (Lisp_Object prompt); + #ifndef HAVE_UNISTD_H extern long time (); #endif @@ -2732,6 +2734,20 @@ Under a windowing system a dialog box will be used if `last-nonmenu-event' is nil, and `use-dialog-box' is non-nil. */) (prompt) Lisp_Object prompt; +{ + Lisp_Object ret; + int count = SPECPDL_INDEX (); + + Finhibit_yield (Qt); + record_unwind_protect (Finhibit_yield, Qnil); + ret = Fyes_or_no1 (prompt); + + unbind_to (count, Qnil); + return ret; +} + +Lisp_Object +Fyes_or_no1 (Lisp_Object prompt) { register Lisp_Object ans; Lisp_Object args[2]; diff --git a/src/minibuf.c b/src/minibuf.c index 1b93228feef..42920eabb78 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -584,8 +584,12 @@ read_minibuf (map, initial, prompt, backup_n, expflag, Fcons (Vminibuffer_history_variable, minibuf_save_list)))))); + + Finhibit_yield (Qt); + record_unwind_protect (Finhibit_yield, Qnil); record_unwind_protect (read_minibuf_unwind, Qnil); minibuf_level++; + /* We are exiting the minibuffer one way or the other, so run the hook. It should be run before unwinding the minibuf settings. Do it separately from read_minibuf_unwind because we need to make sure that diff --git a/src/thread.h b/src/thread.h index 69e801f9a3f..21f04b3f210 100644 --- a/src/thread.h +++ b/src/thread.h @@ -90,3 +90,5 @@ extern pthread_mutex_t global_lock; extern int other_threads_p P_ ((void)); extern int user_thread_p P_ ((void)); + +EXFUN (Finhibit_yield, 1); -- 2.39.5