From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Rodgers Newsgroups: gmane.emacs.help Subject: Re: Inhibit more keyboard event during execution of function Date: Mon, 28 Dec 2009 23:51:40 -0700 Message-ID: References: <87skauojkb.fsf@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1262069624 16674 80.91.229.12 (29 Dec 2009 06:53:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 29 Dec 2009 06:53:44 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Dec 29 07:53:37 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NPVxX-0008MO-QX for geh-help-gnu-emacs@m.gmane.org; Tue, 29 Dec 2009 07:53:36 +0100 Original-Received: from localhost ([127.0.0.1]:48069 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NPVxY-0003Em-32 for geh-help-gnu-emacs@m.gmane.org; Tue, 29 Dec 2009 01:53:36 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NPVw2-0002yt-6I for help-gnu-emacs@gnu.org; Tue, 29 Dec 2009 01:52:02 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NPVvw-0002wc-Of for help-gnu-emacs@gnu.org; Tue, 29 Dec 2009 01:52:00 -0500 Original-Received: from [199.232.76.173] (port=54475 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NPVvw-0002wW-F2 for help-gnu-emacs@gnu.org; Tue, 29 Dec 2009 01:51:56 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]:42812) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NPVvw-0008S2-4I for help-gnu-emacs@gnu.org; Tue, 29 Dec 2009 01:51:56 -0500 Original-Received: from list by lo.gmane.org with local (Exim 4.50) id 1NPVvs-0007uw-EB for help-gnu-emacs@gnu.org; Tue, 29 Dec 2009 07:51:52 +0100 Original-Received: from c-71-237-24-138.hsd1.co.comcast.net ([71.237.24.138]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 29 Dec 2009 07:51:52 +0100 Original-Received: from kevin.d.rodgers by c-71-237-24-138.hsd1.co.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 29 Dec 2009 07:51:52 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 24 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: c-71-237-24-138.hsd1.co.comcast.net User-Agent: Thunderbird 2.0.0.23 (Macintosh/20090812) In-Reply-To: <87skauojkb.fsf@gmail.com> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:70925 Archived-At: Mathias Dahl wrote: > I have made a small game for my kid that lets him press a key and that > will play a sound and display an image. It is implemented as a major > mode with a keymap where each key is defined using `define-key' and > bound to a special play command with a string of what to play (say, > "cow"). Now, it works for me, but when I tested this on my son today he > kept the key pressed way longer than I do, with the effect that the key > repeats, playing the sound many times. Quite annoying. Is there a way to > get around this? I have been thinking of having some timing built in so > that I will not play again unless a certain time has passed. > > Also, even though I tell Emacs to draw the image first (using > `insert-image-file'), it is not displayed until the sound has stopped > playing (I use `play-sound-file'). Any way around this? I don't know if this will work, but you could try let-binding unread-command-events to nil while the sound is being played. The idea is that any input events would be added to the queue, but when the sound is done the queued events would be discarded and the command loop wouldn't see them. -- Kevin Rodgers Denver, Colorado, USA