From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Memnon Anon Newsgroups: gmane.emacs.help Subject: elisp: `quit-process' and `sleep-for' Date: Tue, 24 Aug 2010 19:24:19 +0200 Message-ID: <87hbikuf4m.fsf@mean.albasani.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1282670706 8916 80.91.229.12 (24 Aug 2010 17:25:06 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 24 Aug 2010 17:25:06 +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 Aug 24 19:24:56 2010 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.69) (envelope-from ) id 1OnxF1-0007IR-V1 for geh-help-gnu-emacs@m.gmane.org; Tue, 24 Aug 2010 19:24:56 +0200 Original-Received: from localhost ([127.0.0.1]:58363 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OnxEx-0007sA-1c for geh-help-gnu-emacs@m.gmane.org; Tue, 24 Aug 2010 13:24:51 -0400 Original-Received: from [140.186.70.92] (port=34967 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OnxEX-0007rz-Rz for help-gnu-emacs@gnu.org; Tue, 24 Aug 2010 13:24:26 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OnxEW-0001sU-86 for help-gnu-emacs@gnu.org; Tue, 24 Aug 2010 13:24:25 -0400 Original-Received: from mail-ew0-f41.google.com ([209.85.215.41]:39599) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OnxEW-0001sI-3r for help-gnu-emacs@gnu.org; Tue, 24 Aug 2010 13:24:24 -0400 Original-Received: by ewy28 with SMTP id 28so3810248ewy.0 for ; Tue, 24 Aug 2010 10:24:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:from:to:subject:message-id :user-agent:date:mime-version:content-type; bh=0OkT/yGxx7RbUKJDew4pczgoHsD/MizmEuA5znxQPJc=; b=DYf/eUYTfMgp7Xn2+KuI4rNuvRQSxRn4+1sns87Rjbc744LSaFiZ0pvf+1wEywqDx/ hFdzeH6CcwqrpcEB/uvJtRcbynv27NszOTDhurfQjxu35z5+s9vXbEuqGYp9cW9wA/G9 M5Jv5kJBgnTB4HV1WQ+scFIXA52Mtkvo2Lre4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=from:to:subject:message-id:user-agent:date:mime-version :content-type; b=h/9IyXUATnWufl2syzQWSGhNRLSv/C2GdRdllfXbliE1838FHK1otJiGb+o10GOSkl AVkdXTNNoIvgOvwVLhp3BxIyNfpd8TubBgH06xz3wuN6PidtMlGfE8BVMLb0d7McT+WR 0bJ3ZD56zwUimfAlUz0NT5yuHvHpDeXZJxTxM= Original-Received: by 10.213.40.75 with SMTP id j11mr4655859ebe.28.1282670662661; Tue, 24 Aug 2010 10:24:22 -0700 (PDT) Original-Received: from localhost (e178240129.adsl.alicedsl.de [85.178.240.129]) by mx.google.com with ESMTPS id z55sm468334eeh.21.2010.08.24.10.24.21 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 24 Aug 2010 10:24:22 -0700 (PDT) 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, 2) 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:74796 Archived-At: Hi, I am having trouble with this function: --8<---------------cut here---------------start------------->8--- (defun set_timer (rtcopt value) ; [...] (start-process "alarmclock-mp3" nil "/usr/bin/mplayer" "-quiet" music) (while (y-or-n-p "Snooze?") (when (get-process "alarmclock-mp3") (quit-process "alarmclock-mp3") ; (debug) (sleep-for 100000) (sleep-for 5)) (start-process "alarmclock-mp3" nil "/usr/bin/mplayer" "-quiet" music)) (kill-emacs)) --8<---------------cut here---------------end--------------->8--- Concise: When I call this function, the first sleep-for seems to fail. Only the second one works. Can someone give me a hint why that is so? Long: I found this sesquicolon thingy and wanted to practice some elisp. I turned my laptop into an alarmclock, with suspend-to-ram, 'wake up x minutes from now' or 'wake up at xx:yy' to wake me up. And it seems to work (afaics, but it certainly needs some testing...) As a last step, I wanted to add a snooze functionality: a) Play the mp3. If I type "y': b) stop music c) wait x minutes d) restart at a). However, I found that a single sleep-for was practically ignored. I tried to debug[fn:1] it, but while stepping through with 'd', the sleep-for suddenly works?! When I call the function without the debugger, it seems like only the second sleep-for kicks in (and waits as long as specified); when there is only one, it consequently has no effect at all. So, it works. ... With two sleep-for's where one should be enough. I am a bit puzzled, any hints very welcome. Memnon P.S.: I searched for some [sesquicolon | #!/usr/bin/emacs --script] files out there, but I found next to nothing :(. It's a pitty, would have been very interesting to see some elisp-as-a-general-purpose-scripting-language files to learn from. Footnotes: [fn:1] With (debug) and C-M-x.