From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29815 invoked from network); 14 Jun 2007 13:23:11 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.1 (2007-05-02) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.1 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 14 Jun 2007 13:23:11 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 697 invoked from network); 14 Jun 2007 13:23:05 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 14 Jun 2007 13:23:05 -0000 Received: (qmail 8122 invoked by alias); 14 Jun 2007 13:23:02 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 23560 Received: (qmail 8107 invoked from network); 14 Jun 2007 13:23:00 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 14 Jun 2007 13:23:00 -0000 Received: (qmail 408 invoked from network); 14 Jun 2007 13:23:00 -0000 Received: from cluster-c.mailcontrol.com (168.143.177.190) by a.mx.sunsite.dk with SMTP; 14 Jun 2007 13:22:57 -0000 Received: from rly22c.srv.mailcontrol.com (localhost.localdomain [127.0.0.1]) by rly22c.srv.mailcontrol.com (MailControl) with ESMTP id l5EDMRpk031861 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 14 Jun 2007 14:22:44 +0100 Received: from submission.mailcontrol.com (submission.mailcontrol.com [86.111.216.190]) by rly22c.srv.mailcontrol.com (MailControl) id l5EDLdFm030163 for zsh-workers@sunsite.dk; Thu, 14 Jun 2007 14:21:39 +0100 Received: from cameurexb01.EUROPE.ROOT.PRI ([62.189.241.200]) by rly22c-eth0.srv.mailcontrol.com (envelope-sender Peter.Stephenson@csr.com) (MIMEDefang) with ESMTP id l5EDLWfR029884; Thu, 14 Jun 2007 14:21:39 +0100 (BST) Received: from news01.csr.com ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.1830); Thu, 14 Jun 2007 14:21:31 +0100 Date: Thu, 14 Jun 2007 14:21:31 +0100 From: Peter Stephenson To: Peter Stephenson Cc: zsh-workers@sunsite.dk (Zsh hackers list) Subject: Re: Calling a zle widget from a function Message-ID: <20070614142131.6542c7c7@news01.csr.com> In-Reply-To: <200706122201.l5CM1ouC004185@pwslaptop.csr.com> References: <200706122156.l5CLuPA7004068@pwslaptop.csr.com> <200706122201.l5CM1ouC004185@pwslaptop.csr.com> Organization: CSR X-Mailer: Claws Mail 2.9.1 (GTK+ 2.10.8; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 14 Jun 2007 13:21:31.0908 (UTC) FILETIME=[EC71CC40:01C7AE86] X-Scanned-By: MailControl A-07-07-10 (www.mailcontrol.com) on 10.67.1.132 On Tue, 12 Jun 2007 23:01:50 +0100 Peter Stephenson wrote: > Having done this, it just occurred to me it might be more useful to > have a ":" between the date and the command string, and maybe to > indicate the "-o" in some more useful way for processing > non-interactively. That's a task for tomorrow, I think. This makes zsh_scheduled_events more useful for its intended purpose, and updates calendar to use it. Index: Doc/Zsh/mod_sched.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/mod_sched.yo,v retrieving revision 1.4 diff -u -r1.4 mod_sched.yo --- Doc/Zsh/mod_sched.yo 12 Jun 2007 22:01:38 -0000 1.4 +++ Doc/Zsh/mod_sched.yo 14 Jun 2007 13:09:51 -0000 @@ -48,9 +48,13 @@ A readonly array corresponding to the events scheduled by the tt(sched) builtin. The indices of the array correspond to the numbers shown when tt(sched) is run with no arguments (provided that the -tt(KSH_ARRAYS) option is not set). The value of the -corresponding element is the same as the text shown to the right -of the index in the tt(sched) listing. +tt(KSH_ARRAYS) option is not set). The value of the array +consists of the scheduled time in seconds since the epoch +(see ifnzman(The zsh/datetime Module)\ +ifzman(the section `The zsh/datetime Module') for facilities for +using this number), followed by a colon, followed by any options +(which may be empty but will be preceeded by a `tt(-)' otherwise), +followed by a colon, followed by the command to be executed. The tt(sched) builtin should be used for manipulating the events. Note that this will have an immediate effect on the contents of the array, Index: Functions/Calendar/calendar =================================================================== RCS file: /cvsroot/zsh/zsh/Functions/Calendar/calendar,v retrieving revision 1.3 diff -u -r1.3 calendar --- Functions/Calendar/calendar 26 Mar 2007 14:33:33 -0000 1.3 +++ Functions/Calendar/calendar 14 Jun 2007 13:09:51 -0000 @@ -352,13 +352,8 @@ if [[ -n $sched ]]; then if [[ $next -ge 0 ]]; then # Remove any existing calendar scheduling. - # Luckily sched doesn't delete its schedule in a subshell. - sched | while read line; do - if [[ $line = (#b)[[:space:]]#(<->)[[:space:]]##*[[:space:]]'calendar -s'* ]]; then - # End of pipeline run in current shell, so delete directly. - sched -1 $match[1] - fi - done + i=${"${(@)zsh_scheduled_events#*:*:}"[(I)calendar -s*]} + (( i )) && sched -$i $sched $next calendar "${calopts[@]}" $next $next else $showprog $start $stop \ Index: Src/Builtins/sched.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Builtins/sched.c,v retrieving revision 1.11 diff -u -r1.11 sched.c --- Src/Builtins/sched.c 12 Jun 2007 22:01:39 -0000 1.11 +++ Src/Builtins/sched.c 14 Jun 2007 13:09:55 -0000 @@ -145,40 +145,6 @@ } } -/* - * Format event sch. If sn is zero, allocate string on the heap - * and return it; if non-zero, print with that as scheduled event - * number. - */ - -static -char *schedtext(struct schedcmd *sch, int sn) -{ - char *str, tbuf[40], *flagstr, *endstr; - time_t t; - struct tm *tmp; - - t = sch->time; - tmp = localtime(&t); - ztrftime(tbuf, 20, "%a %b %e %k:%M;%S", tmp); - if (sch->flags & SCHEDFLAG_TRASH_ZLE) - flagstr = "-o "; - else - flagstr = ""; - if (*sch->cmd == '-') - endstr = "-- "; - else - endstr = ""; - if (sn) { - printf("%3d %s %s%s%s\n", sn, tbuf, flagstr, endstr, sch->cmd); - return NULL; - } else { - str = (char *)zhalloc(48 + strlen(sch->cmd)); - sprintf(str, "%s %s%s%s", tbuf, flagstr, endstr, sch->cmd); - return str; - } -} - /**/ static int bin_sched(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func)) @@ -238,8 +204,24 @@ /* given no arguments, display the schedule list */ if (!*argptr) { - for (sn = 1, sch = schedcmds; sch; sch = sch->next, sn++) - (void)schedtext(sch, 1); + for (sn = 1, sch = schedcmds; sch; sch = sch->next, sn++) { + char tbuf[40], *flagstr, *endstr; + time_t t; + struct tm *tmp; + + t = sch->time; + tmp = localtime(&t); + ztrftime(tbuf, 20, "%a %b %e %k:%M:%S", tmp); + if (sch->flags & SCHEDFLAG_TRASH_ZLE) + flagstr = "-o "; + else + flagstr = ""; + if (*sch->cmd == '-') + endstr = "-- "; + else + endstr = ""; + printf("%3d %s %s%s%s\n", sn, tbuf, flagstr, endstr, sch->cmd); + } return 0; } else if (!argptr[1]) { /* other than the two cases above, sched * @@ -365,8 +347,19 @@ ; aptr = ret = zhalloc(sizeof(char **) * (i+1)); - for (sch = schedcmds; sch; sch = sch->next, aptr++) - *aptr = schedtext(sch, 0); + for (sch = schedcmds; sch; sch = sch->next, aptr++) { + char tbuf[40], *flagstr; + time_t t; + + t = sch->time; + sprintf(tbuf, "%ld", t); + if (sch->flags & SCHEDFLAG_TRASH_ZLE) + flagstr = "-o"; + else + flagstr = ""; + *aptr = (char *)zhalloc(5 + strlen(tbuf) + strlen(sch->cmd)); + sprintf(*aptr, "%s:%s:%s", tbuf, flagstr, sch->cmd); + } *aptr = NULL; return ret; -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 To access the latest news from CSR copy this link into a web browser: http://www.csr.com/email_sig.php To get further information regarding CSR, please visit our Investor Relations page at http://ir.csr.com/csr/about/overview