* PATCH: calendar option
@ 2008-12-10 13:25 Peter Stephenson
0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 2008-12-10 13:25 UTC (permalink / raw)
To: Zsh hackers list
Small change to allow you to select how many lines you want to see.
Index: Doc/Zsh/calsys.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/calsys.yo,v
retrieving revision 1.14
diff -u -r1.14 calsys.yo
--- Doc/Zsh/calsys.yo 10 Jun 2008 08:50:36 -0000 1.14
+++ Doc/Zsh/calsys.yo 10 Dec 2008 13:24:13 -0000
@@ -357,6 +357,10 @@
Brief: don't display continuation lines (i.e. indented lines following
the line with the date/time), just the first line.
)
+item(tt(-B) var(lines))(
+Brief: display at most the first var(lines) lines of the calendar
+entry. `tt(-B 1)' is equivalent to `tt(-b)'.
+)
item(tt(-C) var(calfile))(
Explicitly specify a calendar file instead of the value of
the tt(calendar-file) style or the the default tt(~/calendar).
Index: Functions/Calendar/calendar
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/Calendar/calendar,v
retrieving revision 1.8
diff -u -r1.8 calendar
--- Functions/Calendar/calendar 29 Nov 2007 09:49:43 -0000 1.8
+++ Functions/Calendar/calendar 10 Dec 2008 13:24:13 -0000
@@ -60,7 +60,7 @@
########################
# Options with arguments
########################
- ([CnS])
+ ([BCnS])
if [[ -n $optrest ]]; then
optarg=$optrest
optrest=
@@ -72,6 +72,15 @@
return 1
fi
case $opt in
+ (B)
+ # Brief, with number of lines to show.
+ brief=$optarg
+ if (( brief <= 0 )); then
+ print -r "$0: option -$opt requires a positive integer." >&2
+ return 1
+ fi
+ ;;
+
(C)
# Pick the calendar file, overriding style and default.
calendar=$optarg
@@ -289,17 +298,17 @@
fi
(( shown = 0 ))
if (( brief )); then
- showline=${line%%$'\n'*}
+ showline=${(F)${${(f)line}[1,brief]}}
else
showline=$line
- match=()
- # Strip continuation lines starting " #".
- while [[ $showline = (#b)(*$'\n')[[:space:]]##\#[^$'\n']##(|$'\n'(*)) ]]; do
- showline="$match[1]$match[3]"
- done
- # Strip trailing empty lines
- showline=${showline%%[[:space:]]#}
fi
+ match=()
+ # Strip continuation lines starting " #".
+ while [[ $showline = (#b)(*$'\n')[[:space:]]##\#[^$'\n']##(|$'\n'(*)) ]]; do
+ showline="$match[1]$match[3]"
+ done
+ # Strip trailing empty lines
+ showline=${showline%%[[:space:]]#}
if (( showall || (t >= start && (remaining || t <= stop || icount < showcount)) ))
then
$showprog $start $stop "$showline"
--
Peter Stephenson <pws@csr.com> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-12-10 13:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-10 13:25 PATCH: calendar option Peter Stephenson
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).