From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-users@sunsite.auc.dk
Subject: Re: trying to learn zstyle
Date: Tue, 4 Jan 2000 09:17:26 +0100 (MET) [thread overview]
Message-ID: <200001040817.JAA22126@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Peter Stephenson's message of Wed, 22 Dec 1999 23:08:12 +0000
Peter Stephenson wrote:
> ...
>
> Shao Zhang wrote:
> > Hi,
> > I am trying to learn zstyle to do command completion, but I am
> > very very confused how everything works after reading the doc
> > and trying out.
>
> It's quite complicated. I'm working on the chapter of my zsh guide which
> deals with completion to try to help.
Sigh. I hope that all this is mainly a problem of me not being able to
describe things in an understandable way in the docs. And maybe we
should also try to make the manual clearer -- but I fear I'm too deep
into all this code again to know what exactly would be helpful...
> ...
>
> We ought to add things like the handling function to the output of ^Xh
> (that's what tells you the context you're completing in). It helps in this
> case a bit, because if you did it with `hello' you'd have got:
>
> tags in context `:complete::hello:':
> files
> all-files
>
> which would have told you that the only valid tags were files and
> all-files, but not hosts.
The directly-calling-function isn't always helpful (it may be
_arguments or _describe), so the patch below shows what is hopefully
the most interesting part of the function call stack. The problem is
that this may make the display look ugly because it may result in
lines longer than screen width. And making it list the functions one
per line may quickly result in lists longer than screen height. Hm.
Any suggestions for a better layout?
Bye
Sven
diff -u -r oldcompletion/Commands/_complete_help Completion/Commands/_complete_help
--- oldcompletion/Commands/_complete_help Fri Dec 17 21:39:20 1999
+++ Completion/Commands/_complete_help Mon Jan 3 22:09:02 2000
@@ -1,11 +1,8 @@
#compdef -k complete-word \C-xh
_complete_help() {
- local _sort_tags=_help_sort_tags text i
- typeset -A help_tags
- typeset -U help_contexts
-
- help_contexts=()
+ local _sort_tags=_help_sort_tags text i j
+ typeset -A help_funcs help_tags
compadd() { return 1 }
@@ -13,9 +10,12 @@
unfunction compadd
- for i in "$help_contexts[@]"; do
+ for i in "${(@k)help_funcs}"; do
text="${text}
-tags in context \`${i}': ${help_tags[$i]}"
+tags in context ${i}"
+ for j in "${(@s.:.)help_funcs[$i][2,-1]}"; do
+ text="${text}${help_tags[${i}${j}]} (${j})"
+ done
done
compstate[list]='list force'
@@ -25,10 +25,13 @@
}
_help_sort_tags() {
- help_contexts=( "$help_contexts[@]" "$curcontext" )
- help_tags[$curcontext]="${help_tags[$curcontext]}
- ${argv}"
- comptry "$@"
+ local f="${${${funcstack[3,(i)_(main_complete|complete|approximate|normal)]}% *}#_(wanted|requested) }"
+ if [[ "$help_funcs[$curcontext]" != *${f}* ]]; then
+ help_funcs[$curcontext]="${help_funcs[$curcontext]}:${f}"
+ help_tags[${curcontext}${f}]="${help_tags[$curcontext]}
+ ${argv}"
+ comptry "$@"
+ fi
}
_complete_help "$@"
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
next reply other threads:[~2000-01-04 8:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-01-04 8:17 Sven Wischnowsky [this message]
-- strict thread matches above, loose matches on Subject: below --
1999-12-22 0:49 Shao Zhang
1999-12-22 23:08 ` Peter Stephenson
1999-12-22 23:13 ` Peter Stephenson
1999-12-23 1:28 ` Shao Zhang
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=200001040817.JAA22126@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--cc=zsh-users@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).