emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: while-no-input interrupted by *shell*


From: Eli Zaretskii
Subject: Re: while-no-input interrupted by *shell*
Date: Tue, 25 Sep 2018 16:09:40 +0300

> From: Michael Heerdegen <address@hidden>
> Date: Mon, 24 Sep 2018 19:39:48 +0200
> Cc: address@hidden
> 
> Eli Zaretskii <address@hidden> writes:
> 
> > Is it while-no-input that returns immediately, or is it sit-for?
> 
> If I repeat the recipe with only `sit-for', I get no interrupt, so
> `w-n-i' seems involved.
> 
> I started ls -R in *shell* and evaluated
> 
> (progn (sit-for 100)
>        (message "!!!"))
> 
> The *shell* buffer got still filled, but the !!! message only appeared
> after I had hit a key.

It's while-no-input that returns prematurely, indeed.

When output from a subprocess arrives, we insert a buffer-switch event
into the input queue, and that counts as input.  Therefater, any code
that calls maybe_quit will cause while-no-input to throw.  The
backtrace which shows that is below, for the record.

Here's a patch, comments welcome.

diff --git a/lisp/subr.el b/lisp/subr.el
index 7582b6c..59f6949 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -3542,7 +3542,7 @@ with-local-quit
 ;; Don't throw `throw-on-input' on those events by default.
 (setq while-no-input-ignore-events
       '(focus-in focus-out help-echo iconify-frame
-        make-frame-visible selection-request))
+        make-frame-visible selection-request buffer-switch))
 
 (defmacro while-no-input (&rest body)
   "Execute BODY only as long as there's no pending input.
diff --git a/src/keyboard.c b/src/keyboard.c
index 1da5ac0..0d56ea3 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -3569,6 +3569,7 @@ kbd_buffer_store_buffered_event (union 
buffered_input_event *event,
     case ICONIFY_EVENT: ignore_event = Qiconify_frame; break;
     case DEICONIFY_EVENT: ignore_event = Qmake_frame_visible; break;
     case SELECTION_REQUEST_EVENT: ignore_event = Qselection_request; break;
+    case BUFFER_SWITCH_EVENT: ignore_event = Qbuffer_switch; break;
     default: ignore_event = Qnil; break;
     }
 
@@ -11104,6 +11105,8 @@ syms_of_keyboard (void)
   /* Menu and tool bar item parts.  */
   DEFSYM (Qmenu_enable, "menu-enable");
 
+  DEFSYM (Qbuffer_switch, "buffer-switch");
+
 #ifdef HAVE_NTGUI
   DEFSYM (Qlanguage_change, "language-change");
   DEFSYM (Qend_session, "end-session");


Here's the backtrace I promised:

  #0  kbd_buffer_store_buffered_event (event=0x82ad78, hold_quit=0x0)
      at keyboard.c:3579
  #1  0x01154d53 in kbd_buffer_store_event_hold (event=0x82ad78, hold_quit=0x0)
      at keyboard.h:472
  #2  0x011643b5 in kbd_buffer_store_event (event=0x0) at keyboard.c:3439
  #3  0x0116dd10 in record_asynch_buffer_change () at keyboard.c:6866
  #4  0x012bcb86 in read_and_dispose_of_process_output (
      p=0x1c35c68 <dumped_data+4772424>,
      chars=0x82ae68 "0.win32.zip\r\n-rw-rw-rw- 1 Zaretzky       None     "...,
      nbytes=4096, coding=0xfc66b8) at process.c:6049
  #5  0x012bc69d in read_process_output (proc=XIL(0xa000000001c35c68),
      channel=5) at process.c:5937
  #6  0x012bb670 in wait_reading_process_output (time_limit=100, nsecs=0,
      read_kbd=-1, do_display=true, wait_for_cell=XIL(0), wait_proc=0x0,
      just_wait_proc=0) at process.c:5624
  #7  0x01164d76 in kbd_buffer_get_event (kbp=0x82c434, used_mouse_menu=0x0,
      end_time=0x82c9d8) at keyboard.c:3810
  #8  0x0115e58c in read_event_from_main_queue (end_time=0x82c9d8,
      local_getcjmp=0x82c850, used_mouse_menu=0x0) at keyboard.c:2151
  #9  0x0115ea7b in read_decoded_event_from_main_queue (end_time=0x82c9d8,
      local_getcjmp=0x82c850, prev_event=XIL(0), used_mouse_menu=0x0)
      at keyboard.c:2214
  #10 0x0116112a in read_char (commandflag=0, map=XIL(0), prev_event=XIL(0),
      used_mouse_menu=0x0, end_time=0x82c9d8) at keyboard.c:2802
  #11 0x0127e631 in read_filtered_event (no_switch_frame=false,
      ascii_required=false, error_nonascii=false, input_method=true,
      seconds=make_number(100)) at lread.c:672
  #12 0x0127ec54 in Fread_event (prompt=XIL(0),
      inherit_input_method=XIL(0xebd0), seconds=make_number(100)) at lread.c:788
  #13 0x0123c0d9 in funcall_subr (subr=0x16a8ee0 <Sread_event>, numargs=3,
      args=0x82cc38) at eval.c:2853
  #14 0x0123ba8d in Ffuncall (nargs=4, args=0x82cc30) at eval.c:2773
  #15 0x012a700b in exec_byte_code (bytestr=XIL(0x80000000013bc928),
      vector=XIL(0xa0000000013bc938), maxdepth=make_number(7),
      args_template=make_number(769), nargs=1, args=0x82d148) at bytecode.c:629
  #16 0x0123cbef in funcall_lambda (fun=XIL(0xa0000000013bc8f8), nargs=1,
      arg_vector=0x82d140) at eval.c:2974
  #17 0x0123c6bc in apply_lambda (fun=XIL(0xa0000000013bc8f8),
      args=XIL(0xc00000000744f0a0), count=20) at eval.c:2910
  #18 0x01239be8 in eval_sub (form=XIL(0xc00000000744f090)) at eval.c:2283
  #19 0x01231641 in Fprogn (body=XIL(0)) at eval.c:459
  #20 0x01239140 in eval_sub (form=XIL(0xc00000000744d340)) at eval.c:2190
  #21 0x01230f6d in For (args=XIL(0)) at eval.c:372
  #22 0x01239140 in eval_sub (form=XIL(0xc00000000744d370)) at eval.c:2190
  #23 0x01231641 in Fprogn (body=XIL(0)) at eval.c:459
  #24 0x01234854 in Flet (args=XIL(0xc00000000744d390)) at eval.c:973
  #25 0x01239140 in eval_sub (form=XIL(0xc00000000744d3a0)) at eval.c:2190
  #26 0x01231641 in Fprogn (body=XIL(0)) at eval.c:459
  #27 0x01234fa3 in internal_catch (tag=XIL(0x5c6bd88),
      func=0x123153f <Fprogn>, arg=XIL(0xc00000000744d3b0)) at eval.c:1101
  #28 0x01234f42 in Fcatch (args=XIL(0xc00000000744d3c0)) at eval.c:1078
  #29 0x01239140 in eval_sub (form=XIL(0xc00000000744d3d0)) at eval.c:2190
  #30 0x01231641 in Fprogn (body=XIL(0)) at eval.c:459
  #31 0x01234854 in Flet (args=XIL(0xc00000000744cc30)) at eval.c:973
  #32 0x01239140 in eval_sub (form=XIL(0xc00000000744cc40)) at eval.c:2190
  #33 0x01235e05 in internal_lisp_condition_case (var=XIL(0),
      bodyform=XIL(0xc00000000744cc40), handlers=XIL(0xc0000000013bf1e0))
      at eval.c:1307
  #34 0x0123566b in Fcondition_case (args=XIL(0xc00000000744cc60))
      at eval.c:1231
  #35 0x01239140 in eval_sub (form=XIL(0xc00000000744cc70)) at eval.c:2190
  #36 0x01238929 in Feval (form=XIL(0xc00000000744cc70), lexical=XIL(0))
      at eval.c:2058
  #37 0x0123c097 in funcall_subr (subr=0x16a79a0 <Seval>, numargs=2,
      args=0x82e420) at eval.c:2850
  #38 0x0123ba8d in Ffuncall (nargs=3, args=0x82e418) at eval.c:2773
  #39 0x012a700b in exec_byte_code (bytestr=XIL(0x80000000014467d8),
      vector=XIL(0xa0000000014467e8), maxdepth=make_number(10),
      args_template=make_number(1025), nargs=4, args=0x82eb80) at bytecode.c:629
  #40 0x0123cbef in funcall_lambda (fun=XIL(0xa000000001446798), nargs=4,
      arg_vector=0x82eb60) at eval.c:2974
  #41 0x0123bae7 in Ffuncall (nargs=5, args=0x82eb58) at eval.c:2775
  #42 0x0122cbe4 in Ffuncall_interactively (nargs=5, args=0x82eb58)
      at callint.c:252
  #43 0x0123bf84 in funcall_subr (subr=0x16a75c0 <Sfuncall_interactively>,
      numargs=5, args=0x82eb58) at eval.c:2828
  #44 0x0123ba8d in Ffuncall (nargs=6, args=0x82eb50) at eval.c:2773
  #45 0x0123a621 in Fapply (nargs=3, args=0x82eda8) at eval.c:2393
  #46 0x0122d435 in Fcall_interactively (function=XIL(0x120108),
      record_flag=XIL(0), keys=XIL(0xa000000001becb98)) at callint.c:389
  #47 0x0123c0d9 in funcall_subr (subr=0x16a75e0 <Scall_interactively>,
      numargs=3, args=0x82f000) at eval.c:2853
  #48 0x0123ba8d in Ffuncall (nargs=4, args=0x82eff8) at eval.c:2773
  #49 0x012a700b in exec_byte_code (bytestr=XIL(0x8000000001447618),
      vector=XIL(0xa000000001447628), maxdepth=make_number(13),
      args_template=make_number(1025), nargs=1, args=0x82f620) at bytecode.c:629
  #50 0x0123cbef in funcall_lambda (fun=XIL(0xa0000000014475e8), nargs=1,
      arg_vector=0x82f618) at eval.c:2974
  #51 0x0123bae7 in Ffuncall (nargs=2, args=0x82f610) at eval.c:2775
  #52 0x0123af8c in call1 (fn=XIL(0x4398), arg1=XIL(0x120108)) at eval.c:2624
  #53 0x0115bbf5 in command_loop_1 () at keyboard.c:1482
  #54 0x01235ea4 in internal_condition_case (bfun=0x115afb0 <command_loop_1>,
      handlers=XIL(0x5b70), hfun=0x115a1dc <cmd_error>) at eval.c:1336
  #55 0x0115aa1d in command_loop_2 (ignore=XIL(0)) at keyboard.c:1110
  #56 0x01234fa3 in internal_catch (tag=XIL(0xf570),
      func=0x115a9e1 <command_loop_2>, arg=XIL(0)) at eval.c:1101
  #57 0x0115a99c in command_loop () at keyboard.c:1089
  #58 0x01159c08 in recursive_edit_1 () at keyboard.c:695
  #59 0x01159eb2 in Frecursive_edit () at keyboard.c:766
  #60 0x01157494 in main (argc=2, argv=0xa428d8) at emacs.c:1715

  Lisp Backtrace:
  "read-event" (0x82cc38)
  "sit-for" (0x82d140)
  "progn" (0x82d4f8)
  "or" (0x82d6c8)
  "let" (0x82d998)
  "catch" (0x82dc08)
  "let" (0x82ded8)
  "condition-case" (0x82e1a8)
  "eval" (0x82e420)
  "eval-expression" (0x82eb60)
  "funcall-interactively" (0x82eb58)
  "call-interactively" (0x82f000)
  "command-execute" (0x82f618)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]