From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn 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 11:49:01 +0200 Message-ID: <8737x0egvm.fsf@gnu.org> References: <87bnboemqb.fsf@gnu.org> <838u6sy9s1.fsf@gnu.org> <877fmcejgn.fsf@gnu.org> <83ziz8wrun.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1445680231 27424 80.91.229.3 (24 Oct 2015 09:50:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 24 Oct 2015 09:50:31 +0000 (UTC) Cc: Stefan Monnier , 21747@debbugs.gnu.org, "Kim F. Storm" To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Oct 24 11:50:18 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 1ZpvSl-0003LI-LR for geb-bug-gnu-emacs@m.gmane.org; Sat, 24 Oct 2015 11:50:11 +0200 Original-Received: from localhost ([::1]:43640 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpvSk-0003sl-Ur for geb-bug-gnu-emacs@m.gmane.org; Sat, 24 Oct 2015 05:50:10 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56556) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpvSh-0003rB-Nh for bug-gnu-emacs@gnu.org; Sat, 24 Oct 2015 05:50:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZpvSd-0001AB-ME for bug-gnu-emacs@gnu.org; Sat, 24 Oct 2015 05:50:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:44876) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpvSd-0001A5-I3 for bug-gnu-emacs@gnu.org; Sat, 24 Oct 2015 05:50:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1ZpvSd-0000VX-28 for bug-gnu-emacs@gnu.org; Sat, 24 Oct 2015 05:50:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tassilo Horn Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 24 Oct 2015 09:50: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.14456801641898 (code B ref 21747); Sat, 24 Oct 2015 09:50:02 +0000 Original-Received: (at 21747) by debbugs.gnu.org; 24 Oct 2015 09:49:24 +0000 Original-Received: from localhost ([127.0.0.1]:35584 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZpvRz-0000UX-Rl for submit@debbugs.gnu.org; Sat, 24 Oct 2015 05:49:24 -0400 Original-Received: from nsmtp.uni-koblenz.de ([141.26.64.14]:47922) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZpvRe-0000U4-SR for 21747@debbugs.gnu.org; Sat, 24 Oct 2015 05:49:22 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by nsmtp.uni-koblenz.de (Postfix) with ESMTP id 73DBC23B2CE; Sat, 24 Oct 2015 11:49:02 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at uni-koblenz.de Original-Received: from nsmtp.uni-koblenz.de ([127.0.0.1]) by localhost (nsmtp.uni-koblenz.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id A8m3NVcPDfAb; Sat, 24 Oct 2015 11:49:02 +0200 (CEST) Original-Received: from deliver.uni-koblenz.de (deliver.uni-koblenz.de [141.26.64.15]) by nsmtp.uni-koblenz.de (Postfix) with ESMTPS; Sat, 24 Oct 2015 11:49:02 +0200 (CEST) Original-Received: from thinkpad-t440p (dhcp66.uni-koblenz.de [141.26.71.66]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by deliver.uni-koblenz.de (Postfix) with ESMTPSA id 3C50B1A831D; Sat, 24 Oct 2015 11:49:02 +0200 (CEST) In-Reply-To: <83ziz8wrun.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 24 Oct 2015 12:14:40 +0300") User-Agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.0.50 (gnu/linux) 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:107976 Archived-At: 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. >> 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. diff --git a/lisp/subr.el b/lisp/subr.el --- a/lisp/subr.el +++ b/lisp/subr.el @@ -2391,13 +2394,13 @@ (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 (not (sit-for 0 0 t)) - ,@body)))))) + (or (input-pending-p) + ,@body)))))) --8<---------------cut here---------------end--------------->8---