Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: _file_systems & Re: zstyle for _arguments feature request



Oliver Kiddle wrote:

> ...
> 
> > About the general fake style: I'm not sure where the compadd for it
> > could be put. Probably in _setup or _description (where we have all
> > the information about groups and so on), but there might be cases
> > where the matches are then added more than once or into a group which
> > isn't really used for matches (if the user doesn't give  near enogh
> > context). Doing it with help texts further complicates this, of
> > course. Especially if we want to have nice consistent listings
> > because only the completion function decides if the normal matches
> > get descriptions. We would just have to try it, I think.
> 
> I suggest we just try something and see how it goes. Locating it in
> _description might work, assuming that the tag is in the context when
> the style is looked up. It might be a bit strange where more than one
> compadd is used to add matches.

Here is something to play with. It adds the `fake' style, tested in
_description. Still very basic, but matches with descriptions can be
added. I'm not going to commit this until I get positive replies.


Bye
  Sven

diff -ur ../oz/Completion/Base/Core/_description ./Completion/Base/Core/_description
--- ../oz/Completion/Base/Core/_description	Sun Dec 23 17:20:30 2001
+++ ./Completion/Base/Core/_description	Sun Dec 23 17:46:28 2001
@@ -1,6 +1,6 @@
 #autoload
 
-local name gropt=-J format gname hidden hide match opts
+local name gropt=-J format gname hidden hide match opts tag
 
 opts=()
 
@@ -51,6 +51,8 @@
   _comp_ignore=()
 fi
 
+tag="$1"
+
 shift 2
 if [[ -z "$1" && $# -eq 1 ]]; then
   format=
@@ -70,6 +72,17 @@
   else
     set -A "$name" "$opts[@]" "$gropt" -default-
   fi
+fi
+
+if ! (( ${funcstack[2,-1][(I)_description]} )) &&
+   zstyle -a ":completion:${curcontext}:$tag" fake match; then
+
+  local descr
+
+  descr=( "${(@M)match:#*[^\\]:*}" )
+
+  compadd "${(@P)name}" - "${(@)${(@)match:#*[^\\]:*}:s/\\:/:/}"
+  (( $#descr )) && _describe -t "$tag" '' descr "${(@P)name}"
 fi
 
 return 0
diff -ur ../oz/Doc/Zsh/compsys.yo ./Doc/Zsh/compsys.yo
--- ../oz/Doc/Zsh/compsys.yo	Sun Dec 23 17:20:30 2001
+++ ./Doc/Zsh/compsys.yo	Sun Dec 23 17:51:18 2001
@@ -1082,6 +1082,22 @@
 this will also cycle through the names of the files in pathname
 components after the first ambiguous one.
 )
+kindex(fake, completion style)
+item(tt(fake))(
+This style may be set for every completion context and is used to
+specify additional strings to complete in that context.  It's values
+are either the strings to complete with every colon quoted by a
+preceding backslash or strings of the form
+`var(string)tt(:)var(description)'.  In the latter case the var(string)s
+will be shown together with the var(description)s in completion
+listings.
+
+Note that you only really want to use this style for a narrow
+enough context, so that the additional string won't show up in other
+contexts.  Also note the styles tt(fake-files) and tt(fake-parameters)
+which give more control over additional strings to add when completing
+files or parameters.
+)
 kindex(fake-files, completion style)
 item(tt(fake-files))(
 This style is used when completing files and looked up 

-- 
Sven Wischnowsky                           wischnow@xxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author