From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#21747: 25.0.50; while-no-input breaks kbd event handling when called from post-command-hook Date: Sat, 24 Oct 2015 13:35:41 +0300 Message-ID: <83wpucwo3m.fsf@gnu.org> References: <87bnboemqb.fsf@gnu.org> <838u6sy9s1.fsf@gnu.org> <877fmcejgn.fsf@gnu.org> <83ziz8wrun.fsf@gnu.org> <8737x0egvm.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1445682990 834 80.91.229.3 (24 Oct 2015 10:36:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 24 Oct 2015 10:36:30 +0000 (UTC) Cc: monnier@iro.umontreal.ca, 21747@debbugs.gnu.org, storm@cua.dk To: Tassilo Horn Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Oct 24 12:36:17 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZpwBJ-00052v-G1 for geb-bug-gnu-emacs@m.gmane.org; Sat, 24 Oct 2015 12:36:13 +0200 Original-Received: from localhost ([::1]:43725 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpwBI-000884-Ok for geb-bug-gnu-emacs@m.gmane.org; Sat, 24 Oct 2015 06:36:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33501) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpwBD-00085V-Hp for bug-gnu-emacs@gnu.org; Sat, 24 Oct 2015 06:36:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZpwB8-0003EO-Oc for bug-gnu-emacs@gnu.org; Sat, 24 Oct 2015 06:36:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:44886) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpwB8-0003EK-LV for bug-gnu-emacs@gnu.org; Sat, 24 Oct 2015 06:36:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1ZpwB8-0001dz-HQ for bug-gnu-emacs@gnu.org; Sat, 24 Oct 2015 06:36:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 24 Oct 2015 10:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21747 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 21747-submit@debbugs.gnu.org id=B21747.14456829426293 (code B ref 21747); Sat, 24 Oct 2015 10:36:02 +0000 Original-Received: (at 21747) by debbugs.gnu.org; 24 Oct 2015 10:35:42 +0000 Original-Received: from localhost ([127.0.0.1]:35594 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZpwAn-0001dP-23 for submit@debbugs.gnu.org; Sat, 24 Oct 2015 06:35:41 -0400 Original-Received: from mtaout23.012.net.il ([80.179.55.175]:56750) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZpwAj-0001dG-UH for 21747@debbugs.gnu.org; Sat, 24 Oct 2015 06:35:39 -0400 Original-Received: from conversion-daemon.a-mtaout23.012.net.il by a-mtaout23.012.net.il (HyperSendmail v2007.08) id <0NWP00I00ZFBJF00@a-mtaout23.012.net.il> for 21747@debbugs.gnu.org; Sat, 24 Oct 2015 13:35:36 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([84.94.185.246]) by a-mtaout23.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NWQ00IJM03BI330@a-mtaout23.012.net.il>; Sat, 24 Oct 2015 13:35:36 +0300 (IDT) In-reply-to: <8737x0egvm.fsf@gnu.org> X-012-Sender: halo1@inter.net.il X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:107978 Archived-At: > From: Tassilo Horn > Cc: Stefan Monnier , 21747@debbugs.gnu.org, Kim F. Storm > Date: Sat, 24 Oct 2015 11:49:01 +0200 > > Eli Zaretskii writes: > > >> From: Tassilo Horn > >> Cc: 21747@debbugs.gnu.org > >> Date: Sat, 24 Oct 2015 10:53:12 +0200 > >> > >> > Given that, maybe I'm missing something, but what did you expect? The > >> > above literally says that Emacs shall loop indefinitely after > >> > performing each command until there's more input. And that's what you > >> > get. Right? > >> > >> Correct, but when the input eventually arrives, I expect to see its > >> effects as if it had arrived outside of the `while-no-input'. > > > > That effect was not yet produced, because the arriving input was not > > yet consumed by the time while-no-input returns, that input is still > > "pending". For it to be consumed and acted upon, you need another > > crank of the Emacs main loop and another redisplay cycle (which is > > again delayed by the while-no-input loop). So the one-character delay > > goes on forever. > > Ah, ok. I changed `while-no-input' locally to > > (defmacro while-no-input (&rest body) > "Execute BODY only as long as there's no pending input. > If input arrives, that ends the execution of BODY, > and `while-no-input' returns t. Quitting makes it return nil. > If BODY finishes, `while-no-input' returns whatever value BODY produced." > (declare (debug t) (indent 0)) > (let ((catch-sym (make-symbol "input"))) > `(with-local-quit > (catch ',catch-sym > (let ((throw-on-input ',catch-sym)) > (or (input-pending-p) > (progn > (sit-for 0) ;; <== just inserted that > ,@body))))))) > > which seems to fix the issue somehow. With your description, what I > think it does is that it forces the display of the effects of the > command which has interrupted the `while-no-input' in the previous > cycle. More accurately, it invokes redisplay without waiting for more input to arrive. > >> So the question is: should `while-no-input' call (sit-for 0) as the > >> first statement in the `progn' or should functions using > >> `while-no-input' do that on their own? I'd prefer the former because > >> the current behavior is not really obvious (at least not to me nor > >> Artur). > > > > I don't have enough experience in using while-no-input to answer that. > > Perhaps others could chime in and voice their opinions. Maybe we > > should have a discussion on emacs-devel about this (because many > > people who read emacs-devel don't read the bug list). > > Yes, I think that would be a good idea. Originally, `while-no-input' > used (not (sit-for 0 0 t)) instead of (input-pending-p) which I think is > pretty equivalent except that the former forces a redisplay. I've added > Kim to the Cc, so maybe he can speak up. > > --8<---------------cut here---------------start------------->8--- > commit 790e0ef78e306edc0664b8fa5a584c62ec01b444 > Author: Kim F. Storm > Date: Mon Sep 11 22:21:55 2006 +0000 > > (sit-for): Rework to use input-pending-p and cond. > Return nil input is pending on entry also for SECONDS <= 0. > (while-no-input): Use input-pending-p instead of sit-for. This discussion on emacs-devel might be relevant (I think it was the motivation for this change): http://lists.gnu.org/archive/html/emacs-devel/2006-09/msg00300.html