summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2010-03-19 16:39:36 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2010-03-19 16:39:36 +0000
commit5e629a45659e512fae2f3a7f411f12f82defeeb5 (patch)
treeabfcbc51d2265125e5d20249ce8315e7c29ff248
parent95a581f6d46629ccba7a5c1b40e0794598e61325 (diff)
downloadzsh-5e629a45659e512fae2f3a7f411f12f82defeeb5.tar.gz
zsh-5e629a45659e512fae2f3a7f411f12f82defeeb5.tar.xz
zsh-5e629a45659e512fae2f3a7f411f12f82defeeb5.zip
update calendar to run calendar_show in current shell
-rw-r--r--ChangeLog6
-rw-r--r--Functions/Calendar/calendar25
2 files changed, 18 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 003de9c54..7ad83b2e0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2010-03-19  Peter Stephenson  <pws@csr.com>
 
+	* unposted: Functions/Calendar/calendar: update previous
+	change also to perform calendar_show in current shell since
+	it interacts better with zle for use with sched.
+
 	* 27808: Completion/Unix/Type/_files: Use // parameter
 	substitution instead of :gs.  This form is consistent with the
 	rest of the file and has handled quoting correctly for longer.
@@ -12934,5 +12938,5 @@
 
 *****************************************************
 * This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.4938 $
+* $Revision: 1.4939 $
 *****************************************************
diff --git a/Functions/Calendar/calendar b/Functions/Calendar/calendar
index a7aa08595..bbfa9ffb0 100644
--- a/Functions/Calendar/calendar
+++ b/Functions/Calendar/calendar
@@ -42,8 +42,6 @@ if [[ -n $warnstr ]]; then
   fi
 fi
 
-local myschedcmds="${TMPPREFIX:-/tmp/zsh}.sched.$$"
-
 [[ -f $calendar ]] || return 1
 
 # We're not using getopts because we want +... to refer to a
@@ -255,6 +253,10 @@ if (( verbose )); then
   fi
 fi
 
+local mycmds="${TMPPREFIX:-/tmp/zsh}.calendar_cmds.$$"
+touch $mycmds
+chmod 600 $mycmds
+
 # start of subshell for OS file locking
 (
 # start of block for following always to clear up lockfiles.
@@ -322,14 +324,15 @@ fi
     showline=${showline%%[[:space:]]#}
     if (( showall || (t >= start && (remaining || t <= stop || icount < showcount)) ))
     then
-      $showprog $start $stop "$showline"
+      print -r -- ${(qq)showprog} $start $stop ${(qq)showline} >>$mycmds
       (( icount++ ))
       # Doesn't count as "shown" unless the event has now passed.
       (( t <= EPOCHSECONDS )) && (( shown = 1 ))
     elif [[ -n $sched ]]; then
       (( tsched = t - mywarntime ))
       if (( tsched >= start && tsched <= stop)); then
-	$showprog $start $stop "due in ${mywarnstr}: $showline"
+	showline="due in ${mywarnstr}: $showline"
+	print -r -- ${(qq)showprog} $start $stop ${(qq)showline} >>$mycmds
       elif (( tsched < start )); then
 	# We haven't actually shown it, but it's in the past,
 	# so treat it the same.  Should probably rename this variable.
@@ -398,12 +401,12 @@ fi
       i=${"${(@)zsh_scheduled_events#*:*:}"[(I)calendar -s*]}
       {
         (( i )) && print sched -$i
-        print $sched $next calendar "${calopts[@]}" $next $next
-      } >$myschedcmds
+        print -r -- ${(qq)sched} $next calendar "${calopts[@]}" $next $next
+      } >>$mycmds
     else
-      $showprog $start $stop \
-"No more calendar events: calendar not rescheduled.
+      showline="No more calendar events: calendar not rescheduled.
 Run \"calendar -s\" again if you add to it."
+      print -r -- ${(qq)showprog} $start $stop ${(qq)showline} >>$mycmds
     fi
   fi
 
@@ -433,8 +436,6 @@ Old calendar left in $calendar.old." >&2
 exit $rstat
 ) && {
   # Tasks that need to be in the current shell
-  if [[ -f $myschedcmds ]]; then
-    . $myschedcmds
-    rm -f $myschedcmds
-  fi
+  [[ -s $mycmds ]] && . $mycmds
+  rm -f $mycmds
 }