zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: _calendar
@ 2009-04-01 10:53 Peter Stephenson
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2009-04-01 10:53 UTC (permalink / raw)
  To: Zsh hackers list

This adds completion for the calendar function and also makes it
possible to trace what precommand modifiers are in effect, so for
example we can tell if we're executing an external command with the same
name as a function.

Index: Completion/Base/Core/_main_complete
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Core/_main_complete,v
retrieving revision 1.10
diff -u -r1.10 _main_complete
--- Completion/Base/Core/_main_complete	1 Oct 2004 10:29:21 -0000	1.10
+++ Completion/Base/Core/_main_complete	1 Apr 2009 10:45:40 -0000
@@ -32,6 +32,9 @@
       _saved_insert="${compstate[insert]}" \
       _saved_colors="$ZLS_COLORS"
 
+# _precommand sets this to indicate we are following a precommand modifier
+local -a precommands
+
 typeset -U _lastdescr _comp_ignore _comp_colors
 
 [[ -z "$curcontext" ]] && curcontext=:::
Index: Completion/Unix/Command/_calendar
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_calendar,v
retrieving revision 1.1
diff -u -r1.1 _calendar
--- Completion/Unix/Command/_calendar	12 Mar 2008 23:35:26 -0000	1.1
+++ Completion/Unix/Command/_calendar	1 Apr 2009 10:45:41 -0000
@@ -1,12 +1,34 @@
 #compdef calendar
 
-_arguments \
-  '-a[process files of all users]' \
-  '-A[print today and the following num days]:number of days:' \
-  '-b[enforce special KOI8 date calculation mode]' \
-  '-B[print today and the previous num days]:number of days:' \
-  '-f[use file as the default calendar]:calendar file:_files' \
-  '-l[print today and the following num days]:number of days:' \
-  '-w[print today and the following num days only if today is Friday]:number of days:' \
-  '-t[act as though today is the date specified]:date:'
+if [[ $+functions[calendar] -eq 1 && -z $precommands[(r)command] ]]; then
+  # The shell function is loaded, and we're not instructed to
+  # use an external command, so complete that.
+  _arguments \
+    '-a[show all calendar items]' \
+    '-b[brief, display first line only]' \
+    '-d[move events to done file]' \
+    '-D[never move events to done file]' \
+    '-r[show all remaining items from start or now]' \
+    '-s[use sched to schedule a warning]' \
+    '-v[verbose]' \
+    '-B[select number of lines to display]:lines: ' \
+    '-C[select calendar file]:calendar file:_path_files' \
+    '-n[select max number of events]:max number of events: ' \
+    '-S[select show programme]:show programme:_command_names' \
+    '1:date/time: ' \
+    '(-r)2:end date/time: '
+else
+  # This is only one particular version of calendar.
+  # Some variant of BSD, I think.
 
+  _arguments \
+    '-a[process files of all users]' \
+    '-A[print today and the following num days]:number of days:' \
+    '-b[enforce special KOI8 date calculation mode]' \
+    '-B[print today and the previous num days]:number of days:' \
+    '-f[use file as the default calendar]:calendar file:_files' \
+    '-l[print today and the following num days]:number of days:' \
+    '-w[print today and the following num days only if today is Friday]:number of days:' \
+    '-t[act as though today is the date specified]:date:'
+
+fi
Index: Completion/Zsh/Command/_command
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Command/_command,v
retrieving revision 1.2
diff -u -r1.2 _command
--- Completion/Zsh/Command/_command	19 Aug 2007 23:31:31 -0000	1.2
+++ Completion/Zsh/Command/_command	1 Apr 2009 10:45:41 -0000
@@ -2,6 +2,8 @@
 
 local ret
 
+# indicate if this is a precommand modifier
+[[ $service = command ]] && precommands+=(command)
 if [[ CURRENT -ge 3 ]]; then
   compset -n 2
   _normal && ret=0
Index: Completion/Zsh/Command/_precommand
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Command/_precommand,v
retrieving revision 1.6
diff -u -r1.6 _precommand
--- Completion/Zsh/Command/_precommand	30 Aug 2008 11:49:20 -0000	1.6
+++ Completion/Zsh/Command/_precommand	1 Apr 2009 10:45:41 -0000
@@ -1,5 +1,8 @@
 #compdef - nohup eval time rusage noglob nocorrect exec catchsegv aoss
 
+# precommands is made local in _main_complete
+precommands+=($words[1])
+
 shift words
 (( CURRENT-- ))
 

-- 
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] 2+ messages in thread

* PATCH: _calendar
@ 2008-03-12 23:32 Clint Adams
  0 siblings, 0 replies; 2+ messages in thread
From: Clint Adams @ 2008-03-12 23:32 UTC (permalink / raw)
  To: zsh-workers

This is the BSD calendar command as used in Debian and not the calsys
function.

Index: Completion/Unix/Command/_calendar
===================================================================
RCS file: Completion/Unix/Command/_calendar
diff -N Completion/Unix/Command/_calendar
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Completion/Unix/Command/_calendar	12 Mar 2008 23:30:25 -0000
@@ -0,0 +1,12 @@
+#compdef calendar
+
+_arguments \
+  '-a[process files of all users]' \
+  '-A[print today and the following num days]:number of days:' \
+  '-b[enforce special KOI8 date calculation mode]' \
+  '-B[print today and the previous num days]:number of days:' \
+  '-f[use file as the default calendar]:calendar file:_files' \
+  '-l[print today and the following num days]:number of days:' \
+  '-w[print today and the following num days only if today is Friday]:number of days:' \
+  '-t[act as though today is the date specified]:date:'
+


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-04-01 10:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-01 10:53 PATCH: _calendar Peter Stephenson
  -- strict thread matches above, loose matches on Subject: below --
2008-03-12 23:32 Clint Adams

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).