From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Vinicius Jose Latorre Newsgroups: gmane.emacs.devel Subject: Re: How to know if a key is pressed without getting it? Date: Sun, 26 Sep 2010 20:21:46 -0300 Message-ID: <4C9FD58A.4070205@ig.com.br> References: <4C9F609A.8010303@ig.com.br> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Trace: dough.gmane.org 1285543109 23005 80.91.229.12 (26 Sep 2010 23:18:29 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 26 Sep 2010 23:18:29 +0000 (UTC) Cc: "GNU Emacs \(devel\)" To: Andreas Schwab Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Sep 27 01:18:28 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 1P00UF-0006j3-Fd for ged-emacs-devel@m.gmane.org; Mon, 27 Sep 2010 01:18:27 +0200 Original-Received: from localhost ([127.0.0.1]:36374 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P00UE-0005T6-SJ for ged-emacs-devel@m.gmane.org; Sun, 26 Sep 2010 19:18:26 -0400 Original-Received: from [140.186.70.92] (port=59763 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P00UA-0005SE-6V for emacs-devel@gnu.org; Sun, 26 Sep 2010 19:18:23 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1P00U9-0004C3-0R for emacs-devel@gnu.org; Sun, 26 Sep 2010 19:18:22 -0400 Original-Received: from mail-yw0-f41.google.com ([209.85.213.41]:62424) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P00U8-0004Br-Sn for emacs-devel@gnu.org; Sun, 26 Sep 2010 19:18:20 -0400 Original-Received: by ywl5 with SMTP id 5so2140054ywl.0 for ; Sun, 26 Sep 2010 16:18:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=j1dWzCCGFbutKTEF5JShGxS92o2ZguVmY9UGBS1FV8c=; b=FAYpXBzMjjv5avdCJvxsC0ZruM7Ff60uQGw1vgrtz09f8RJ74zi+lYaZdni8qhOlTX 5MFcwmRRUyWel/AK6Bwc/ej6LrxiNM55Yl1MzQzvDtXe9e/CbQJ8DdlYPm8tiEXeq2Vl /LyRsP1ymaZROkxYNmcjW+Tcsbr2NYKgTTVZA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=k7HLYy0xNf1HSMNylcfxmYAT2VBQrGo964M61WcPmgkYMlwt260qXGd9UZrjN5r9Po Ge3duwYa27qHod8/FMdxez95tRQ+yrCUxStzZpT3F/i6L6LQlmVlBd69VLCuMLCvh8dT Y8MmFt0JFs+vJjv6F77qdQ/6yKNc1/tJChIvE= Original-Received: by 10.150.138.4 with SMTP id l4mr7778504ybd.237.1285543099761; Sun, 26 Sep 2010 16:18:19 -0700 (PDT) Original-Received: from [192.168.0.101] ([201.82.131.118]) by mx.google.com with ESMTPS id q1sm7174456ybk.8.2010.09.26.16.18.17 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 26 Sep 2010 16:18:18 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.13) Gecko/20100914 SeaMonkey/2.0.8 In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) 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:130958 Archived-At: >> Does anyone know how to know if a key is pressed without getting it in >> Emacs (like kbhit like function)? >> > input-pending-p is a built-in function in `C source code'. > > (input-pending-p) > > Return t if command input is currently available with no wait. > Actually, the value is nil only if we can be sure that no input is available; > if there is a doubt, the value is t. > Well, Óscar Fuentes also sent me an email about input-pending-p. 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). So, input-pending-p does not work as kbhit function. I'm thinking that this function is not implemented in Emacs.