From: Peter Stephenson <pws@csr.com>
To: Zsh hackers list <zsh-workers@sunsite.dk>
Subject: Re: Proposal to use patterns in fake-files style
Date: Mon, 30 Apr 2007 18:19:11 +0100 [thread overview]
Message-ID: <20070430181911.36ad3f58.pws@csr.com> (raw)
In-Reply-To: <200704301208.l3UC81Ol017197@news01.csr.com>
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
parent reply other threads:[~2007-04-30 17:19 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <200704301208.l3UC81Ol017197@news01.csr.com>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070430181911.36ad3f58.pws@csr.com \
--to=pws@csr.com \
--cc=zsh-workers@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).