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

Re: PATCH: dynamic named directories



I'll proof read the docs a bit (ie i'll read them, i can't read without
proof reading anyway) *does that*, okay, only one comment.

2008/9/25 Peter Stephenson <pws@xxxxxxx>:
> Problem: six feet deep in WiFi and UWB bugs to fix.  Solution:  do
> something else entirely.
>
> This morning I had a brainwave/brainstorm that turned out to be easy to
> implement and test without interfering with the rest of the shell, which
> is the sort of feature I like.  I'm sure you'll tell me if it's a stupid
> idea.
>
> It's based on the way I use an Emacs function suite called "bufname"
> that a colleague and I wrote a few years ago.  I have lots of parallel
> directory hierarchies with slightly different names at different levels,
> so normal static directory naming isn't really flexible enough.
>
> Now you can use ~[<stuff>] and <stuff> gets passed down to a function
> zsh_directory_name, which either parses it and picks an appropriate
> directory or refuses.  (If the function isn't defined this syntax is
> treated the way it always was, which typically wasn't all that useful.)
> There's also a mechanism for going the other way.  See documentation and
> examples.
>
> Much of the patch is actually another simplification to doshfunc() which
> was obvious when I worked out what the third argument was for.  It
> should mean any PM_* flags applicable to functions (such as PM_TAGGED)
> are handled more consistently.
>
> Index: Doc/Zsh/expn.yo
> ===================================================================
> RCS file: /cvsroot/zsh/zsh/Doc/Zsh/expn.yo,v
> retrieving revision 1.91
> diff -u -r1.91 expn.yo
> --- Doc/Zsh/expn.yo     16 Jun 2008 16:39:18 -0000      1.91
> +++ Doc/Zsh/expn.yo     25 Sep 2008 12:39:43 -0000
> @@ -1308,8 +1308,73 @@
>  option exchanges the effects of `tt(~PLUS())' and `tt(~-)' where they are
>  followed by a number.
>
> -cindex(directories, named)
> -cindex(named directories)
> +subsect(Dynamic named directories)
> +cindex(directories, named, dynamic)
> +cindex(named directories, dynamicic)
> +cindex(dynamic named directories)
> +
> +The feature described here is only available if the shell function
> +tt(zsh_directory_name) exists.
> +
> +A `tt(~)' followed by a string var(namstr) in unquoted square brackets is
> +treated specially as a dynamic directory name.  Note that the first
> +unquoted closing square bracket always terminates var(namstr).  The shell
> +function is passed two arguments: the string tt(n) (for name) and
> +var(namstr).  It should either set the array tt(reply) to a single element
> +which is the directory corresponding to the name and return status zero
> +(executing an assignment as the last statement is usually sufficient), or
> +it should return status non-zero.  In the former case the element of reply

the what element of reply? i guess the first?

-- 
Mikael Magnusson



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