Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Proposal to use patterns in fake-files style
- X-seq: zsh-workers 23363
- From: Peter Stephenson <pws@xxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxxxxx>
- Subject: Re: Proposal to use patterns in fake-files style
- Date: Mon, 30 Apr 2007 18:19:11 +0100
- In-reply-to: <200704301208.l3UC81Ol017197@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- Organization: Cambridge Silicon Radio
- References: <200704301208.l3UC81Ol017197@xxxxxxxxxxxxxx>
Peter Stephenson <pws@xxxxxxx> wrote:
> Is anybody out there going to be disadvantaged if I turn the directory
> part of the fake-files completion style into a pattern?
This is the patch in question.
Index: Doc/Zsh/compsys.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v
retrieving revision 1.198
diff -u -r1.198 compsys.yo
--- Doc/Zsh/compsys.yo 27 Feb 2007 20:44:02 -0000 1.198
+++ Doc/Zsh/compsys.yo 30 Apr 2007 13:15:24 -0000
@@ -1340,12 +1340,17 @@
`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.
+such files really exist. The dir may be a pattern; pattern characters
+or colons in var(dir) should be quote with a backslash to be treated
+literally.
This can be useful on systems that support special filesystems whose
top-level pathnames can not be listed or generated with glob patterns.
It can also be used for directories for which one does not have read
permission.
+
+The pattern form can be used to add a certain `magic' entry
+to all directories on a particular filing system.
)
kindex(fake-parameters, completion style)
item(tt(fake-parameters))(
Index: Src/Zle/computil.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/computil.c,v
retrieving revision 1.101
diff -u -r1.101 computil.c
--- Src/Zle/computil.c 21 Jan 2007 22:49:56 -0000 1.101
+++ Src/Zle/computil.c 30 Apr 2007 13:15:26 -0000
@@ -4247,14 +4247,20 @@
char *m, *f, *p, *t, *a, c;
int sl = strlen(skipped) + 1;
struct stat st1, st2;
+ Patprog pprog;
for (; (f = *fake); fake++) {
f = dupstring(f);
for (p = t = f; *p; p++) {
if (*p == ':')
break;
- else if (*p == '\\' && p[1])
+ else if (*p == '\\' && p[1] == ':') {
+ /*
+ * strip quoted colons here; rely
+ * on tokenization to strip other backslashes
+ */
p++;
+ }
*t++ = *p;
}
if (*p) {
@@ -4262,9 +4268,12 @@
if (!*p)
continue;
+ tokenize(f);
+ pprog = patcompile(f, PAT_STATIC, NULL);
+ untokenize(f);
for (node = firstnode(orig); node; incnode(node)) {
if ((m = (char *) getdata(node)) &&
- (!strcmp(f, m) ||
+ ((pprog ? pattry(pprog, m) : !strcmp(f, m)) ||
(!stat(f, &st1) && !stat((*m ? m : "."),
&st2) && st1.st_dev == st2.st_dev &&
st1.st_ino == st2.st_ino))) {
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
To access the latest news from CSR copy this link into a web browser: http://www.csr.com/email_sig.php
To get further information regarding CSR, please visit our Investor Relations page at http://ir.csr.com/csr/about/overview
Messages sorted by:
Reverse Date,
Date,
Thread,
Author