Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: completion with globbing, take 2
- X-seq: zsh-users 3440
- From: "E. Jay Berkenbilt" <ejb@xxxxxx>
- To: schaefer@xxxxxxxxxxxxxxxxxxxxxxx
- Subject: Re: completion with globbing, take 2
- Date: Mon, 18 Sep 2000 18:07:40 -0400
- Cc: zsh-users@xxxxxxxxxxxxxx
- In-reply-to: <1000918172840.ZM29857@xxxxxxxxxxxxxxxxxxxxxxx>	(schaefer@xxxxxxxxxxxxxxxxxxxxxxx)
- Mailing-list: contact zsh-users-help@xxxxxxxxxxxxxx; run by ezmlm
- References: <200009171750.NAA05647@xxxxxxxxxxx> 	<1000917184320.ZM19505@xxxxxxxxxxxxxxxxxxxxxxx> 	<200009172303.TAA07756@xxxxxxxxxxx> 	<200009180017.UAA08871@xxxxxxxxxxx> 	<000001c02136$b9c1f2a0$21c9ca95@xxxxxxxxxxxxxx> 	<000701c0213d$2434b6d0$21c9ca95@xxxxxxxxxxxxxx> 	<000001c02157$2ceaa360$21c9ca95@xxxxxxxxxxxxxx> <1000918172840.ZM29857@xxxxxxxxxxxxxxxxxxxxxxx>
>   } Also, after reading the code, I don't believe it is true that _match
>   } won't do anything without matcher-list set -- see analysis and
>   } questions below.
>
>   Right, I was confused, as Andrej has already pointed out.  (The completion
>   system has a tendency to do that to almost anyone from time to time, even
>   Sven.)
Actually, I'll admit to being heartened to see others getting confused
about this.  It is pretty confusing. :-)
>   On Sep 17,  8:17pm, E. Jay Berkenbilt wrote:
>   } Subject: completion and globbing, part 2
>   }
>   } It occurred to me that if the analysis in my last message was true,
>   } the following would work:
>   [...]
>   } This does, in fact, give me exactly the behavior I'm looking for
>   } without using _expand or _match.
>
>   Does it?  What happens when you complete a pattern that matches only
>   directories?  (I get, it inserts all the directories and adds a slash
>   after only the last one, so if I press TAB again I get completions in
>   that last directory, which seems unlikely to be what you'd want.)
Well, in fact, I never do this with rmdir.  I chose it as an example
only because it's easy to work with and has simple completion
functions.  I really use this with cvs add and cvs rm where it is
great.  If I create a bunch of test files, I can do cvs add *TAB and
automatically not get the files that are already registered or files
that are in .cvsignore.  A great timesaver.  What I used to do is 
cvs add `cvs -qn update | fgrep '?' | awk '{print $2}'` (or something
like that) which isn't tooo bad but is obviously not as nice as cvs
add *TAB. :-)
>   Incidentally, the three lines
>
>      ret=1
>      _complete && ret=0
>      return ret
>
>   are equivalent to just
>
>      _complete
>      return
>
>   and if _complete is the last line in the function, you don't even need
>   the `return'.
Nice to know.  So I guess zsh functions are like lisp and perl -- the
value of the last statement is the return value -- but with the
additional feature that return with no arguments returns the last
value.... I'll have to play a bit to see what the real rules are or
check the documentation.  Over time as I gain more experience in more
languages and work with more people's code, I find myself
philosophically leaning more toward the Python mentality of making
everything explicit, but that's another topic for another forum....
--
E. Jay Berkenbilt (ejb@xxxxxx)  |  http://www.ql.org/q/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author