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

PATCH: Re: more wishes with automounter

[ replying to different messages with different subjects... ]

Peter Stephenson wrote:

> You need to use the fake style.  Something like
> zstyle ':completion:*:files' fake /var/autofs/nfs:stuff
> except you have to work out what to put for `stuff'.  The manual page
> implies you can put more than one name there but doesn't say how to do it.

One just separates them by spaces. The patch changes the manual.

Bart Schaefer wrote:

> On Sep 12,  5:20am, Bart Schaefer wrote:
> }
> } Hmm.  I've just been playing with zsh on a machine at work that has an
> } automounted directory, and I can't reproduce the behavior you described.
> [...]
> } with the trailing slash, the mount happens and I get completions.  This
> } happens both with and without the new completion system loaded.
> I'm sorry, I was mistaken about having loaded new completion.  With the
> new completion system *properly* loaded, I *can* get this to happen.
> So here's the answer to your question:
>     zstyle -e ':completion:*' file-patterns '[[ -d $PREFIX:h/. ]]'
> This tests whether the prefix (or "/", if there's no prefix, but that's
> harmless) contains a "." directory, then ignores the result; so the only
> effect is to force the directory to be automounted.  Since it does not
> set a value for $reply (see the "zstyle -e" doc), completion proceeds as
> if the style were not set at all.

But that's a bit ugly isn't it? I mean: the completion system should
be able to complete there without such hacks. (And I once was even
thinking about enabling it to complete the mounted directories...)

For now, the patch below uses something similar to what you suggest
(using globbing, not [[..]]). Not very nice, but works for me.

In another message, Bart wrote:

> On Sep 13, 11:32am, Alexandre Duret-Lutz wrote:
> } Subject: Re: more wishes with automounter
> }
> }     zstyle -e ':completion:*' file-patterns \
> }       '[[ $PREFIX == /nfs/[^/]# ]] && \
> }         { setopt noglob ; reply=(*(@,/)) ; setopt glob }'
> } 
> } Leads to:
> } 
> } ~ % ls /nfs/<TAB>
> } _path_files:327: bad pattern: /nfs/*(@
> This is because _files splits the file-patterns at commas on line 58.  I'm
> not sure why, or how to fix it.  It might be to replace
>     pat="${${${sdef%%:${tag}*}//\\:/:}//,/ }"
> with
>     pat="${${${sdef%%:${tag//,/ }*}//\\:/:}}"
> but I fear that only Sven knows for sure. 

Time to blush for me: that ${..//,/ } seems to be a leftover from an
earlier version. There one could give multiple patterns separated by
commas (for the same tag, in the same string, as in '*.c,*.x:foo *.o:bar').
That was changed to allow brace expansions: '{*.c,*.x}:foo' and at
that time I should have removed the code above. Ahem.

> In any case, a qualifier with
> a comma in it would interact badly with the file-sort tag, because it will
> be rewritten as e.g. *(@,/Om), which is not what you meant.

No that would be ok, `o' and `O' work, like some of the older
qualifiers, independent of the (comma-separated sub-)list in which
they are given. I've now put that in the manual.


Index: Completion/Core/_files
RCS file: /cvsroot/zsh/zsh/Completion/Core/_files,v
retrieving revision 1.14
diff -u -r1.14 _files
--- Completion/Core/_files	2000/06/15 09:06:21	1.14
+++ Completion/Core/_files	2000/10/05 07:27:44
@@ -55,7 +55,7 @@
   for sdef in "$def[@]"; do
-    pat="${${${sdef%%:${tag}*}//\\:/:}//,/ }"
+    pat="${${sdef%%:${tag}*}//\\:/:}"
     (( $tried[(I)${(q)pat}] )) && continue
Index: Completion/Core/_path_files
RCS file: /cvsroot/zsh/zsh/Completion/Core/_path_files,v
retrieving revision 1.30
diff -u -r1.30 _path_files
--- Completion/Core/_path_files	2000/08/08 10:32:49	1.30
+++ Completion/Core/_path_files	2000/10/05 07:27:44
@@ -315,6 +315,10 @@
+    # Force auto-mounting. There might be a better way...
+    : ${^tmp1}/${PREFIX}${SUFFIX}/.(N/)
     # Get the matching files by globbing.
     if [[ "$tpre$tsuf" = */* ]]; then
Index: Doc/Zsh/compsys.yo
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v
retrieving revision 1.96
diff -u -r1.96 compsys.yo
--- Doc/Zsh/compsys.yo	2000/09/21 05:16:22	1.96
+++ Doc/Zsh/compsys.yo	2000/10/05 07:27:45
@@ -1010,9 +1010,10 @@
 kindex(fake, completion style)
-Currently, this style is only used when completing files and lookup up 
+Currently, this style is only used when completing files and looked up 
 with the tag tt(files).  Its values are of the form
-`var(dir)tt(:)var(names...)'.  This will add the var(names) as
+`var(dir)tt(:)var(names...)'.  This will add the var(names) (strings
+separated by spaces) as
 possible matches when completing in the directory var(dir), even if no 
 such files really exist.
Index: Doc/Zsh/expn.yo
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/expn.yo,v
retrieving revision 1.22
diff -u -r1.22 expn.yo
--- Doc/Zsh/expn.yo	2000/08/29 06:35:40	1.22
+++ Doc/Zsh/expn.yo	2000/10/05 07:27:46
@@ -1748,7 +1748,11 @@
 More than one of these lists can be combined, separated by commas. The
 whole list matches if at least one of the sublists matches (they are
-`or'ed, the qualifiers in the sublists are `and'ed).
+`or'ed, the qualifiers in the sublists are `and'ed).  Some qualifiers,
+however, affect all matches generated, independent of the sublist in
+which they are given.  These are the qualifiers `tt(M)', `tt(T)',
+`tt(N)', `tt(D)', `tt(n)', `tt(o)', `tt(O)' and the subscripts given
+in brackets (`tt([...])').
 If a `tt(:)' appears in a qualifier list, the remainder of the expression in
 parenthesis is interpreted as a modifier (see noderef(Modifiers)

Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx

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