diff options
author | Michael Albinus <michael.albinus@gmx.de> | 2018-08-30 21:29:04 +0200 |
---|---|---|
committer | Michael Albinus <michael.albinus@gmx.de> | 2018-08-30 21:29:04 +0200 |
commit | 54b92132e1ec16565d59d6d9f8ff8910f38843b2 (patch) | |
tree | 894a20a1c835c5da28d0b74a26667efed5aac189 /src/keyboard.c | |
parent | 3cc42bb60099c32f64e57d2ee33c8321adba7942 (diff) | |
download | emacs-54b92132e1ec16565d59d6d9f8ff8910f38843b2.tar.gz emacs-54b92132e1ec16565d59d6d9f8ff8910f38843b2.tar.bz2 emacs-54b92132e1ec16565d59d6d9f8ff8910f38843b2.zip |
Handle thread-signal towards the main thread (Bug#32502)
* doc/lispref/threads.texi (Basic Thread Functions):
* etc/NEWS: Document thread-signal towards the main thread.
* lisp/emacs-lisp/thread.el: New package.
* src/keyboard.c (read_char): Check for Qthread_event.
(kbd_buffer_get_event, make_lispy_event): Handle THREAD_EVENT.
(syms_of_keyboard): Declare Qthread_event.
(keys_of_keyboard): Add thread-handle-event to special-event-map.
* src/termhooks.h (enum event_kind): Add THREAD_EVENT.
* src/thread.c: Include "keyboard.h".
(poll_suppress_count) Don't declare extern.
(Fthread_signal): Raise event if THREAD is the main thread. (Bug#32502)
* test/src/thread-tests.el (thread): Require it.
(threads-signal-main-thread): New test.
Diffstat (limited to 'src/keyboard.c')
-rw-r--r-- | src/keyboard.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index 7fafb41fcc5..008d3b9d7c0 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -2828,6 +2828,9 @@ read_char (int commandflag, Lisp_Object map, #ifdef USE_FILE_NOTIFY || EQ (XCAR (c), Qfile_notify) #endif +#ifdef THREADS_ENABLED + || EQ (XCAR (c), Qthread_event) +#endif || EQ (XCAR (c), Qconfig_changed_event)) && !end_time) /* We stopped being idle for this event; undo that. This @@ -3739,7 +3742,7 @@ kbd_buffer_get_event (KBOARD **kbp, } #endif /* subprocesses */ -#if !defined HAVE_DBUS && !defined USE_FILE_NOTIFY +#if !defined HAVE_DBUS && !defined USE_FILE_NOTIFY && !defined THREADS_ENABLED if (noninteractive /* In case we are running as a daemon, only do this before detaching from the terminal. */ @@ -3750,7 +3753,7 @@ kbd_buffer_get_event (KBOARD **kbp, *kbp = current_kboard; return obj; } -#endif /* !defined HAVE_DBUS && !defined USE_FILE_NOTIFY */ +#endif /* !defined HAVE_DBUS && !defined USE_FILE_NOTIFY && !defined THREADS_ENABLED */ /* Wait until there is input available. */ for (;;) @@ -3900,6 +3903,9 @@ kbd_buffer_get_event (KBOARD **kbp, #ifdef HAVE_DBUS case DBUS_EVENT: #endif +#ifdef THREADS_ENABLED + case THREAD_EVENT: +#endif #ifdef HAVE_XWIDGETS case XWIDGET_EVENT: #endif @@ -5983,6 +5989,13 @@ make_lispy_event (struct input_event *event) } #endif /* HAVE_DBUS */ +#ifdef THREADS_ENABLED + case THREAD_EVENT: + { + return Fcons (Qthread_event, event->arg); + } +#endif /* THREADS_ENABLED */ + #ifdef HAVE_XWIDGETS case XWIDGET_EVENT: { @@ -11078,6 +11091,10 @@ syms_of_keyboard (void) DEFSYM (Qdbus_event, "dbus-event"); #endif +#ifdef THREADS_ENABLED + DEFSYM (Qthread_event, "thread-event"); +#endif + #ifdef HAVE_XWIDGETS DEFSYM (Qxwidget_event, "xwidget-event"); #endif @@ -11929,6 +11946,12 @@ keys_of_keyboard (void) "dbus-handle-event"); #endif +#ifdef THREADS_ENABLED + /* Define a special event which is raised for thread signals. */ + initial_define_lispy_key (Vspecial_event_map, "thread-event", + "thread-handle-event"); +#endif + #ifdef USE_FILE_NOTIFY /* Define a special event which is raised for notification callback functions. */ |