From: Tanaka Akira <akr@jaist.ac.jp>
To: zsh-workers@sunsite.auc.dk
Subject: Re: PATCH: completion
Date: 21 Aug 1999 08:22:55 +0900 [thread overview]
Message-ID: <rsq672a11gw.fsf@crane.jaist.ac.jp> (raw)
In-Reply-To: Sven Wischnowsky's message of "Fri, 20 Aug 1999 14:59:20 +0200 (MET DST)"
In article <199908201259.OAA00799@beta.informatik.hu-berlin.de>,
Sven Wischnowsky <wischnow@informatik.hu-berlin.de> writes:
> Not that easy and some people probably don't like the way option names
> are completed with this patch, but still...
I tried to use this for "patch" and few problems are found and
fixed. And I thought some about _arguments.
1. The help message may not suited for _long_options.
For example, help message of "patch" contains:
-p NUM --strip=NUM Strip NUM leading components from file names.
The options are not separeted by ",".
I avoid this problem by modifying the help message.
# http://www.ldl.jaist.ac.jp/~akr/junk/patch-2.5.3-cvsaware-19990820.patch
But, in general, help messages may not able to modify. Therefore I
think it is useful that _arguments can handle options started with
"--".
# Also, if _arguments supports options started with "--" directly,
# opt-spec to specify both "--xxx=yyy" and "--xxx yyy" at once may
# useful.
2. I would like to refer the parsed arguments in completers.
I think this is useful in many cases.
For example, if the completer for port of telnet can refer host
argument, it can complete ports precisely: "nntp" for news servers,
"smtp" for mail servers, etc. If the completer for emacs can check
whether the argument of -f is batch-byte-compile, we can complete only
*.el.
3. "xterm -e" style.
Some options take arguments up to end of command line.
If _arguments supports this style of options, it is also useful for
_cvs, I suppose. Because first non-option argument for cvs command
behaves like that.
For example, I would like to describe _cvs as:
_cvs () {
_arguments -s \
'-d:cvsroot:...' \
... \
'**:subcommand:_cvs_subcommand'
}
_cvs_subcommand () {
if [[ CURRENT = 1 ]]; then
compadd -- add commit diff ...
else
case $words[1] in
add) _arguments -s '-k+:keyword expansion:...' ...;;
...
esac
fi
}
Index: Completion/Base/_arguments
===================================================================
RCS file: /projects/zsh/zsh/Completion/Base/_arguments,v
retrieving revision 1.1.1.4
diff -u -F^( -r1.1.1.4 _arguments
--- _arguments 1999/08/20 13:29:01 1.1.1.4
+++ _arguments 1999/08/20 22:25:02
@@ -158,12 +158,12 @@
else
uns=''
if [[ -n "$single" && "$ws[1]" = [-+]* ]]; then
- if [[ $#opts -ne 0 &&
+ if [[ ${#${(kj::)opts[(R)?*]#?}} -ne 0 &&
"$ws[1]" = ${ws[1][1]}*[${(kj::)opts[(R)?*]#?}] ]]; then
def="$opts[${ws[1][1]}${ws[1][-1]}]"
uns="${ws[1][2,-1]}"
opt=''
- elif [[ $#mopts -ne 0 &&
+ elif [[ ${#${(kj::)mopts[(R)?*]#?}} -ne 0 &&
"$ws[1]" = ${ws[1][1]}*[${(kj::)mopts[(R)?*]#?}] ]]; then
def="$mopts[${ws[1][1]}${ws[1][-1]}]"
uns="${ws[1][2,-1]}"
@@ -457,7 +457,7 @@
[[ $#long -ne 0 &&
( "$compconfig[option_prefix]" != *(long|all)* ||
"$PREFIX" = --* ) ]] && \
- _long_options && ret=0
+ _long_options "$long[@]" && ret=0
fi
fi
Index: Completion/Base/_long_options
===================================================================
RCS file: /projects/zsh/zsh/Completion/Base/_long_options,v
retrieving revision 1.1.1.7
diff -u -F^( -r1.1.1.7 _long_options
--- _long_options 1999/08/19 14:41:32 1.1.1.7
+++ _long_options 1999/08/20 22:25:02
@@ -135,7 +135,7 @@
set -- "$@" '*=FILE*:file:_files' '*=(DIR|PATH)*:directory:_files -/' '*:unknown:'
- while [[ $# -gt 1 ]]; do
+ while [[ $# -gt 0 ]]; do
# First, we get the pattern and the action to use and take them
# from the positional parameters.
@@ -265,6 +265,8 @@
action=($=action)
${(e)action[1]} "$expl[@]" ${(e)~action[2,-1]}
fi
+ else
+ _message "$descr"
fi
# We found the option string, return.
Index: Completion/User/_patch
===================================================================
RCS file: _patch
diff -N _patch
--- /dev/null Fri Apr 17 15:56:34 1998
+++ _patch Fri Aug 20 22:25:03 1999
@@ -0,0 +1,32 @@
+#compdef patch
+
+_arguments -s \
+ '-p+:number:(0)' \
+ '-F+:lines:' \
+ '-l' '-c' '-e' '-n' '-u' '-N' '-R' \
+ '-i+:patch file:_files' \
+ '-o+:output file:_files' \
+ '-r+:reject file:_files' \
+ '-D+:name:' \
+ '-E' '-Z' '-T' \
+ '-b' \
+ '-V+:version control style:(simple numbered existing)' \
+ '-B+:backup path prefix:' \
+ '-Y+:basename basename prefix:_files' \
+ '-z+:backup file suffix:(.bak)' \
+ '-g+:NUM:' \
+ '-t' '-f' '-s' \
+ '-d+:chdir to:_files -/' \
+ '-v' \
+ ':original file:_files' \
+ ':patch file:_files' \
+ -- \
+ '*=NUM*:number:(0)' \
+ '*=LINES*:lines:' \
+ '*=PATCHFILE*:patch file:_files' \
+ '*=FILE*:file:_files' \
+ '*=NAME*:name:' \
+ '*=WORD*:quoting style:(literal shell shell-always c escape)' \
+ '*=STYLE*:version control style:(simple numbered existing)' \
+ '*=SUFFIX*:backup file suffix:(.bak)' \
+ '*=DIR*:chdir to:_files -/'
--
Tanaka Akira
next prev parent reply other threads:[~1999-08-20 23:23 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-08-20 12:59 Sven Wischnowsky
1999-08-20 23:22 ` Tanaka Akira [this message]
1999-08-21 8:39 ` Tanaka Akira
1999-08-21 17:47 ` Tanaka Akira
-- strict thread matches above, loose matches on Subject: below --
2000-02-21 9:50 Sven Wischnowsky
1999-10-28 8:12 Sven Wischnowsky
1999-10-28 6:58 Sven Wischnowsky
1999-10-27 8:42 Sven Wischnowsky
1999-10-27 16:39 ` Bart Schaefer
1999-10-27 7:14 Sven Wischnowsky
1999-10-27 21:26 ` Tanaka Akira
1999-10-26 13:17 Sven Wischnowsky
1999-10-26 13:01 Oliver Kiddle
1999-10-26 13:35 ` Zefram
1999-10-26 11:03 Sven Wischnowsky
1999-10-26 17:17 ` Bart Schaefer
1999-10-26 17:22 ` Tanaka Akira
1999-10-26 17:32 ` Tanaka Akira
1999-08-30 9:30 Sven Wischnowsky
1999-08-27 7:03 Sven Wischnowsky
1999-08-27 8:29 ` Tanaka Akira
1999-08-28 6:01 ` Tanaka Akira
1999-08-26 13:52 Sven Wischnowsky
1999-08-26 12:20 Sven Wischnowsky
1999-08-26 13:17 ` Tanaka Akira
1999-08-26 17:56 ` Tanaka Akira
1999-08-25 12:57 Sven Wischnowsky
1999-08-25 12:54 Sven Wischnowsky
1999-08-25 8:24 Sven Wischnowsky
1999-08-26 10:54 ` Tanaka Akira
1999-08-24 10:43 Sven Wischnowsky
1999-08-25 1:56 ` Tanaka Akira
1999-08-24 9:12 Sven Wischnowsky
1999-08-24 10:04 ` Tanaka Akira
1999-08-23 13:46 Sven Wischnowsky
1999-08-23 16:16 ` Tanaka Akira
1999-08-24 15:56 ` Tanaka Akira
1999-08-23 12:00 Sven Wischnowsky
1999-08-23 9:32 Sven Wischnowsky
1999-08-23 10:54 ` Tanaka Akira
1999-08-20 7:42 Sven Wischnowsky
1999-08-19 13:59 Sven Wischnowsky
1999-08-19 10:44 Sven Wischnowsky
1999-08-19 14:38 ` Tanaka Akira
1999-08-24 13:46 ` Peter Stephenson
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=rsq672a11gw.fsf@crane.jaist.ac.jp \
--to=akr@jaist.ac.jp \
--cc=zsh-workers@sunsite.auc.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).