From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Phil Sainty" Newsgroups: gmane.emacs.bugs Subject: bug#14820: 24.3; elisp manual: How to write good idle timer worker functions? Date: Thu, 11 Jul 2013 03:31:25 +1200 (NZST) Message-ID: <50216.121.99.89.166.1373470285.squirrel@mail.orcon.net.nz> References: <51DABDE6.10904@orcon.net.nz> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1373470340 1478 80.91.229.3 (10 Jul 2013 15:32:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 10 Jul 2013 15:32:20 +0000 (UTC) Cc: 14820@debbugs.gnu.org To: "Stefan Monnier" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jul 10 17:32:17 2013 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 1UwwNG-0007LF-FZ for geb-bug-gnu-emacs@m.gmane.org; Wed, 10 Jul 2013 17:32:10 +0200 Original-Received: from localhost ([::1]:57112 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UwwNG-0001zW-0u for geb-bug-gnu-emacs@m.gmane.org; Wed, 10 Jul 2013 11:32:10 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50314) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UwwN9-0001tV-KK for bug-gnu-emacs@gnu.org; Wed, 10 Jul 2013 11:32:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UwwN8-0006SS-67 for bug-gnu-emacs@gnu.org; Wed, 10 Jul 2013 11:32:03 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:51172) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UwwN8-0006SN-3e for bug-gnu-emacs@gnu.org; Wed, 10 Jul 2013 11:32:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1UwwN7-0006uo-Kf for bug-gnu-emacs@gnu.org; Wed, 10 Jul 2013 11:32:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Phil Sainty" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 10 Jul 2013 15:32:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 14820 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 14820-submit@debbugs.gnu.org id=B14820.137347029326510 (code B ref 14820); Wed, 10 Jul 2013 15:32:01 +0000 Original-Received: (at 14820) by debbugs.gnu.org; 10 Jul 2013 15:31:33 +0000 Original-Received: from localhost ([127.0.0.1]:45488 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1UwwMe-0006tW-Uj for submit@debbugs.gnu.org; Wed, 10 Jul 2013 11:31:33 -0400 Original-Received: from nctlincom02.orcon.net.nz ([60.234.4.76]:50369) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1UwwMb-0006tK-Gm for 14820@debbugs.gnu.org; Wed, 10 Jul 2013 11:31:31 -0400 Original-Received: from mx5.orcon.net.nz (mx5.orcon.net.nz [219.88.242.55]) by nctlincom02.orcon.net.nz (8.14.3/8.14.3/Debian-9.4) with ESMTP id r6AFVPLh013139 for <14820@debbugs.gnu.org>; Thu, 11 Jul 2013 03:31:26 +1200 Original-Received: from Debian-exim by mx5.orcon.net.nz with local (Exim 4.69) (envelope-from ) id 1UwwMX-0006LM-Te for 14820@debbugs.gnu.org; Thu, 11 Jul 2013 03:31:25 +1200 Original-Received: from [172.16.100.202] (helo=mail.orcon.net.nz) by mx5.orcon.net.nz with esmtp (Exim 4.69) (envelope-from ) id 1UwwMX-0006L0-Gq; Thu, 11 Jul 2013 03:31:25 +1200 Original-Received: from 121.99.89.166 (SquirrelMail authenticated user 15631029) by mail.orcon.net.nz with HTTP; Thu, 11 Jul 2013 03:31:25 +1200 (NZST) In-Reply-To: User-Agent: SquirrelMail/1.4.5 X-Priority: 3 (Normal) Importance: Normal X-DSPAM-Check: by mx5.orcon.net.nz on Thu, 11 Jul 2013 03:31:25 +1200 X-DSPAM-Result: Innocent X-DSPAM-Processed: Thu Jul 11 03:31:25 2013 X-DSPAM-Confidence: 0.5713 X-DSPAM-Probability: 0.0000 X-Bayes-Prob: 0.8354 (Score 2, tokens from: @@RPTN, default) X-CanIt-Geo: No geolocation information available for 172.16.100.202 X-CanItPRO-Stream: base:default X-Canit-Stats-ID: 05JWDvqjT - 461582f7b3cb - 20130711 X-Scanned-By: CanIt (www . roaringpenguin . com) on 172.16.100.175 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: 140.186.70.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:76187 Archived-At: Stefan Monnier wrote: > Currently, Emacs doesn't support such "background tasks" well. > Documentation could help, but I think it's not really worth the > trouble. Better come up with a package that provides support > for it. Well surely you'd agree that writing such a package is going to be more much difficult without documentation? That is essentially the problem I ran into here, after all. At the absolute minimum, that page definitely needs to mention `sit-for' / "(elisp) Waiting" and `accept-process-output' / "(elisp) Accepting Output". After all, when specific pit-falls are mentioned, I think that the available facilities for working around them warrant at least a passing mention. (Honestly, the merest mention of these two functions after the description of the problems of blocking other timers and processes would have saved me many hours, so it's worth it just for the potential to save someone else from being similarly stumped. I'd simply never had cause to use them before, so it wasn't *at all* obvious where to look.) Having found my way to the latter, and run some experiments with generating output from a shell while running my idle timer code, I've managed to answer my own question about `sit-for' (which is that it does not solve the problem of accepting process output), but determined that (unsurprisingly) calling `(accept-process-output)' does provide a solution, so I believe I'm on my way to resolving my original issue. I do still think that if there were some nice easy-to-use wrappers around the functionality that Emacs *does* provide, we could say something a little more positive about the situation -- that *despite* not supporting "background tasks" well, Emacs makes it easy to fake them! > IIRC someone posted some packages that try to provide support > for related issues, but I can't find the corresponding email. Ah, that's a shame; but thank you for looking. Maybe someone else remembers what those were? Failing that, if I end up with something that seems useful and generic, I'll submit it for consideration. -Phil p.s. Although I *think* I now know what I'm doing here, I don't want to close this issue just yet. I'm very interested in any and all comments on this subject, if any other people wish to chip in with their thoughts?