diff options
author | Michael Albinus <michael.albinus@gmx.de> | 2018-07-17 12:03:43 +0200 |
---|---|---|
committer | Michael Albinus <michael.albinus@gmx.de> | 2018-07-17 12:03:43 +0200 |
commit | 798cbac170f05a749a4d5130d64d83c202f09158 (patch) | |
tree | 8541cd26117f0aee8bc02612f98d99fe49127ef2 /src/thread.c | |
parent | 94a16e7360b69191001bc594ab1b66f2b6bf97c2 (diff) | |
download | emacs-798cbac170f05a749a4d5130d64d83c202f09158.tar.gz |
Add variable main-thread, fix Bug#32169
* doc/lispref/threads.texi (Basic Thread Functions): Add example,
how to propagate signals to the main thread. Describe variable
`main-thread'. Document optional argument CLEANUP of
`thread-last-error'.
* src/thread.c (Fthread_last_error): Add optional argument
CLEANUP. (Bug#32169)
(main-thread): New defvar.
* test/src/thread-tests.el (thread-last-error): Adapt declaration.
(main-thread): Declare.
(threads-main-thread): New test.
(threads-errors): Extend test.
Diffstat (limited to 'src/thread.c')
-rw-r--r-- | src/thread.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/thread.c b/src/thread.c index 3eba25b7b43..754d286e9f8 100644 --- a/src/thread.c +++ b/src/thread.c @@ -973,11 +973,17 @@ DEFUN ("all-threads", Fall_threads, Sall_threads, 0, 0, 0, return result; } -DEFUN ("thread-last-error", Fthread_last_error, Sthread_last_error, 0, 0, 0, - doc: /* Return the last error form recorded by a dying thread. */) - (void) +DEFUN ("thread-last-error", Fthread_last_error, Sthread_last_error, 0, 1, 0, + doc: /* Return the last error form recorded by a dying thread. +If CLEANUP is non-nil, remove this error form from history. */) + (Lisp_Object cleanup) { - return last_thread_error; + Lisp_Object result = last_thread_error; + + if (!NILP (cleanup)) + last_thread_error = Qnil; + + return result; } @@ -1083,4 +1089,13 @@ syms_of_threads (void) DEFSYM (Qthreadp, "threadp"); DEFSYM (Qmutexp, "mutexp"); DEFSYM (Qcondition_variable_p, "condition-variable-p"); + + DEFVAR_LISP ("main-thread", + Vmain_thread, + doc: /* The main thread of Emacs. */); +#ifdef THREADS_ENABLED + XSETTHREAD (Vmain_thread, &main_thread); +#else + Vmain_thread = Qnil; +#endif } |