From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk (Zsh hackers list)
Subject: PATCH: _calendar
Date: Wed, 01 Apr 2009 11:53:57 +0100 [thread overview]
Message-ID: <1497.1238583237@csr.com> (raw)
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
next reply other threads:[~2009-04-01 10:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-01 10:53 Peter Stephenson [this message]
-- strict thread matches above, loose matches on Subject: below --
2008-03-12 23:32 Clint Adams
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1497.1238583237@csr.com \
--to=pws@csr.com \
--cc=zsh-workers@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).