* Re: Proposal to use patterns in fake-files style
[not found] <200704301208.l3UC81Ol017197@news01.csr.com>
@ 2007-04-30 17:19 ` Peter Stephenson
0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 2007-04-30 17:19 UTC (permalink / raw)
To: Zsh hackers list
Peter Stephenson <pws@csr.com> 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@csr.com> 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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-04-30 17:19 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <200704301208.l3UC81Ol017197@news01.csr.com>
2007-04-30 17:19 ` Proposal to use patterns in fake-files style Peter Stephenson
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).