From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: How to know if a key is pressed without getting it? Date: Mon, 27 Sep 2010 01:36:36 +0200 Message-ID: References: <4C9F609A.8010303@ig.com.br> <4C9FD58A.4070205@ig.com.br> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1285544211 26041 80.91.229.12 (26 Sep 2010 23:36:51 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 26 Sep 2010 23:36:51 +0000 (UTC) Cc: Andreas Schwab , "GNU Emacs \(devel\)" To: Vinicius Jose Latorre Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Sep 27 01:36:47 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1P00lu-0001kd-DD for ged-emacs-devel@m.gmane.org; Mon, 27 Sep 2010 01:36:42 +0200 Original-Received: from localhost ([127.0.0.1]:42049 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P00lt-0003BL-Lw for ged-emacs-devel@m.gmane.org; Sun, 26 Sep 2010 19:36:41 -0400 Original-Received: from [140.186.70.92] (port=60385 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P00lo-0003Ap-1V for emacs-devel@gnu.org; Sun, 26 Sep 2010 19:36:37 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1P00lm-0006b3-NH for emacs-devel@gnu.org; Sun, 26 Sep 2010 19:36:35 -0400 Original-Received: from fencepost.gnu.org ([140.186.70.10]:50323) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P00lm-0006az-Lv for emacs-devel@gnu.org; Sun, 26 Sep 2010 19:36:34 -0400 Original-Received: from dyn.144-85-185-002.dsl.vtx.ch ([144.85.185.2]:24839 helo=fmsmemgm.homelinux.net) by fencepost.gnu.org with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1P00lm-0001Oa-9M; Sun, 26 Sep 2010 19:36:34 -0400 Original-Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 4DBD46611D; Mon, 27 Sep 2010 01:36:36 +0200 (CEST) In-Reply-To: <4C9FD58A.4070205@ig.com.br> (Vinicius Jose Latorre's message of "Sun, 26 Sep 2010 20:21:46 -0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:130961 Archived-At: > I defined the following function using input-pending-p: > (defun test-input () > (read-char "char: ") > (while (input-pending-p) > (insert (format "{%S}" unread-command-events))) > (message "{%S} END" last-input-char)) > Execute the function above via: M-: (test-input) RET > Then hold space key. > The only message returned is "{32} END" followed by all spaces that > I pressed (except the first one). This probably depends on how quickly the read-char returns and the input-pending-p gets run, but it seems reasonable to expect it to be run in (much) less time than your repeat rate, so when the input-pending-p is run, there is indeed no input pending yet. Stefan