diff --git a/lisp/simple.el b/lisp/simple.el index 6dc08ff0eb0..de3152fde2d 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -2752,6 +2752,7 @@ command-completion--command-for-this-buffer-function (let ((if (cconv--interactive-helper--if f))) `(interactive ,(if (functionp if) `(funcall ',if) if)))) +(defvar background-thread nil) (defun command-execute (cmd &optional record-flag keys special) ;; BEWARE: Called directly from the C code. "Execute CMD as an editor command. @@ -2803,7 +2804,17 @@ command-execute (execute-kbd-macro final prefixarg)) (t ;; Pass `cmd' rather than `final', for the backtrace's sake. - (prog1 (call-interactively cmd record-flag keys) + (prog1 + (let ((f (lambda () (call-interactively cmd record-flag keys)))) + (cond ((or background-thread t) + (funcall f)) + (t + (thread-join + (make-thread + (lambda () + (let ((background-thread (current-thread))) + (funcall f))) + (format "command: %S" cmd)))))) (when-let ((info (and (symbolp cmd) (not (get cmd 'command-execute-obsolete-warned))