zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@ifh.de>
To: zsh-workers@math.gatech.edu (Zsh hackers list)
Subject: Directory completion
Date: Mon, 15 Sep 1997 17:41:24 +0200	[thread overview]
Message-ID: <199709151541.RAA01864@hydra.ifh.de> (raw)
In-Reply-To: "Peter Stephenson"'s message of "Mon, 15 Sep 1997 10:05:31 MET." <199709150805.KAA23396@sgi.ifh.de>

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@ifh.de>       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.


  reply	other threads:[~1997-09-15 15:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-09-11 16:53 Is anybody maintaining c2z and lete2ctl? Bart Schaefer
1997-09-15  8:05 ` Peter Stephenson
1997-09-15 15:41   ` Peter Stephenson [this message]
1997-09-15 16:11     ` Directory completion Peter Stephenson
1997-09-15 16:31     ` Bruce Stephens
1997-09-15 16:35     ` Peter Stephenson
1997-09-15 16:39 Peter Stephenson

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=199709151541.RAA01864@hydra.ifh.de \
    --to=pws@ifh.de \
    --cc=zsh-workers@math.gatech.edu \
    /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).