Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Directory completion
- X-seq: zsh-workers 3492
- From: Peter Stephenson <pws@xxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxxx (Zsh hackers list)
- Subject: Directory completion
- Date: Mon, 15 Sep 1997 17:41:24 +0200
- In-reply-to: "Peter Stephenson"'s message of "Mon, 15 Sep 1997 10:05:31 MET." <199709150805.KAA23396@xxxxxxxxxx>
I wrote about lete2ctl:
> It might work a little better if we had special directory completion, like
> tcsh, instead of relying on ordinary globbing. Maybe it's time we bit
> the bullet and did this: I can't believe the code would be large or
> difficult.
As I thought, it's completely trivial: it just hijacks the usual code
for completing paths. Here's a patch for 3.1. Now you can write
compctl -/g '*.ps'
instead of some circumlocution like:
compctl -g '*.ps' + -g '*(-/)' gv
which doesn't allow you to look for subdirectories of directories with
ps files in. Writing things like '-/g ...' should be an easy and
sensible habit to get into. Since it uses the usual path code,
symbolic links are traced properly without you having to think about
them. In technical terms, `it's not flakey any more'.
Any comments (such as `why didn't we do this ages ago'?)
*** Doc/Zsh/compctl.yo.dir Tue Aug 5 09:49:45 1997
--- Doc/Zsh/compctl.yo Mon Sep 15 17:05:00 1997
***************
*** 98,104 ****
texinode(Option Flags)(Alternative Completion)(Command Flags)(Programmable Completion)
sect(Option Flags)
startlist()
! list([ tt(-fcFBdeaRGovNAIOPZEnbjrzu) ])
list([ tt(-k) var(array) ] [ tt(-g) var(globstring) ] \
[ tt(-s) var(subststring) ])
list([ tt(-K) var(function) ] [ tt(-H) var(num pattern) ])
--- 98,104 ----
texinode(Option Flags)(Alternative Completion)(Command Flags)(Programmable Completion)
sect(Option Flags)
startlist()
! list([ tt(-fcFBdeaRGovNAIOPZEnbjrzu/) ])
list([ tt(-k) var(array) ] [ tt(-g) var(globstring) ] \
[ tt(-s) var(subststring) ])
list([ tt(-K) var(function) ] [ tt(-H) var(num pattern) ])
***************
*** 123,128 ****
--- 123,131 ----
startitem()
item(tt(-f))(
Filenames and filesystem paths.
+ )
+ item(tt(-/)){
+ Just filesystem paths.
)
item(tt(-c))(
Command names, including aliases, shell functions, builtins
*** Src/Zle/comp.h.dir Mon Sep 15 16:35:31 1997
--- Src/Zle/comp.h Mon Sep 15 16:35:45 1997
***************
*** 140,145 ****
--- 140,146 ----
#define CC_QUOTEFLAG (1<<25)
#define CC_EXTCMDS (1<<26)
#define CC_RESWDS (1<<27)
+ #define CC_DIRS (1<<28)
#define CC_RESERVED (1<<31)
*** Src/Zle/compctl.c.dir Mon Sep 15 16:36:33 1997
--- Src/Zle/compctl.c Mon Sep 15 16:36:35 1997
***************
*** 176,181 ****
--- 176,184 ----
case 'Q':
cct.mask |= CC_QUOTEFLAG;
break;
+ case '/':
+ cct.mask |= CC_DIRS;
+ break;
case 'k':
if ((*argv)[1]) {
cct.keyvar = (*argv) + 1;
*** Src/Zle/zle_tricky.c.dir Mon Sep 15 16:57:36 1997
--- Src/Zle/zle_tricky.c Mon Sep 15 17:27:39 1997
***************
*** 2519,2525 ****
/* Handle completion of files specially (of course). */
! if ((cc->mask & (CC_FILES | CC_COMMPATH)) || cc->glob) {
/* s1 and s2 point to the last/first slash in the prefix/suffix. */
if (!s1)
s1 = rpre;
--- 2519,2525 ----
/* Handle completion of files specially (of course). */
! if ((cc->mask & (CC_FILES | CC_DIRS | CC_COMMPATH)) || cc->glob) {
/* s1 and s2 point to the last/first slash in the prefix/suffix. */
if (!s1)
s1 = rpre;
***************
*** 2635,2641 ****
prpre = pp;
}
}
! }
/* The compctl has a glob pattern (compctl -g). */
if (cc->glob) {
int ns, pl = strlen(prpre), o;
--- 2635,2642 ----
prpre = pp;
}
}
! } else if (cc->mask && CC_DIRS)
! gen_matches_files(1, 0, 0);
/* The compctl has a glob pattern (compctl -g). */
if (cc->glob) {
int ns, pl = strlen(prpre), o;
--
Peter Stephenson <pws@xxxxxx> Tel: +49 33762 77366
WWW: http://www.ifh.de/~pws/ Fax: +49 33762 77413
Deutsches Elektronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, Platanenallee 6, 15738 Zeuthen, Germany.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author