zsh-workers
 help / color / mirror / code / Atom feed
* Is anybody maintaining c2z and lete2ctl?
@ 1997-09-11 16:53 Bart Schaefer
  1997-09-15  8:05 ` Peter Stephenson
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 1997-09-11 16:53 UTC (permalink / raw)
  To: zsh-workers

I noticed they haven't changed for quite some time (at least, not in the
zsh 3.0.x sources, I haven't checked 3.1.x).

Here are a batch of tweaks to the 3.0.4 c2z:

* Fix the usage comment
 (can't give both -l and -i, must use one or the other)
* Optionally take the name of a file to convert
  (instead of always converting .cshrc and optionally also .login)
* Use $ZSH_NAME in preference to $VERSION to detect zsh
  (hopefully nobody exports ZSH_NAME and then runs `sh')
* Change $cwd to $PWD in aliases converted to functions
* Delete assignment to PWD from the environment
* Fix handling of tcsh `correct' variable
  (what was `setopt autocorrect' supposed to do?)
* Upcase all `prompt' variables
  (zsh maps prompt->PROMPT but not prompt2->PROMPT2 et. al.)
* Change `!' to `%h' in PROMPT
  (old csh history number references)

There are probably other tcsh-isms that could be incorporated.

Index: Misc/c2z
--- c2z	1997/06/27 16:55:18	1.1.1.1
+++ c2z	1997/09/11 16:40:18
@@ -20,7 +20,7 @@
 # procedures.
 #
 # usage:
-#	c2z [-i] [-l]
+#	c2z [-i | -l | filename]
 #
 # You can use this script in your .zshrc or .zlogin files to load your
 # regular csh environment into zsh; for example, in .zlogin:
@@ -39,27 +39,30 @@
 # If we're zsh, we can run "- csh" to get the complete environment.
 #
 MINUS=""
-LOGIN=""
+LOADFILE=""
 INTERACT=""
-case "$VERSION" in
+CSH=csh
+case "$ZSH_NAME$ZSH_VERSION$VERSION" in
 zsh*)
     case $1 in
     -l*) MINUS="-" ;;
     -i*) INTERACT="-i" ;;
+    *) LOADFILE="source $1" CSH="csh -f";;
     esac
     if [[ -o INTERACTIVE ]]; then INTERACT="-i"; fi
     setopt nobanghist
     ;;
 *)
     case $1 in
-    -l*) LOGIN="source ~/.login" ;;
+    -l*) LOADFILE="source ~/.login" ;;
     -i*) INTERACT="-i" ;;
+    *) LOADFILE="source $1" CSH="csh -f";;
     esac
     ;;
 esac
 
-( eval $MINUS csh $INTERACT ) <<EOF 2>&1 >/dev/null
-$LOGIN
+( eval $MINUS $CSH $INTERACT ) <<EOF 2>&1 >/dev/null
+$LOADFILE
 alias >! /tmp/cz$$.a
 setenv >! /tmp/cz$$.e
 set >! /tmp/cz$$.v
@@ -79,6 +82,7 @@
     -e 's/^\([^'"$T"']*\)'"$T"'\(.*\)$/alias -- \1='"'\2'/" \
     /tmp/cz$$.3
 sed -e 's/![:#]*/$/g' \
+    -e 's/\$cwd/$PWD/' \
     -e 's/^\([^'"$T"']*\)'"$T"'\(.*\)$/\1 () { \2 }/' \
     /tmp/cz$$.2
 
@@ -87,6 +91,7 @@
 
 # Would be nice to deal with embedded newlines, e.g. in TERMCAP, but ...
 sed -e '/^SHLVL/d' \
+    -e '/^PWD/d' \
     -e "s/'/'"\\\\"''"/g \
     -e "s/^\([A-Za-z0-9_]*=\)/export \1'/" \
     -e "s/$/'/"
@@ -101,16 +106,19 @@
 	s/$/'"'/"'
 	}' |
 sed -e '/^argv=/d' -e '/^cwd=/d' -e '/^filec=/d' -e '/^status=/d' \
+	 -e '/^autolist=/s/.*/setopt autolist/' \
+	 -e '/^correct=all/s//setopt correctall/' \
+	 -e '/^correct=/s//setopt correct/' \
 	 -e '/^histchars=/s//HISTCHARS=/' \
 	 -e '/^history=/s//HISTSIZE=/' \
 	 -e '/^home=/s//HOME=/' \
 	 -e '/^ignoreeof=/s/.*/setopt ignoreeof/' \
 	 -e '/^noclobber=/s/.*/setopt noclobber/' \
 	 -e '/^notify=/d' \
+	 -e '/^prompt=/s/!/%h/' \
+	 -e 's/^prompt/PROMPT/' \
 	 -e '/^showdots=/s/.*/setopt globdots/' \
-    -e '/^savehist=/s//HISTFILE=\~\/.zhistory SAVEHIST=/' \
-	 -e '/^autolist=/s/.*/setopt autolist/' \
-	 -e '/^correct=[cmd]*/s//setopt autocorrect/' \
+	 -e '/^savehist=/s//HISTFILE=\~\/.zhistory SAVEHIST=/' \
 	 -e '/^who=/s//WATCHFMT=/'
 
 

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Is anybody maintaining c2z and lete2ctl?
  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   ` Directory completion Peter Stephenson
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Stephenson @ 1997-09-15  8:05 UTC (permalink / raw)
  To: Zsh hackers list

"Bart Schaefer" wrote:
> I noticed they haven't changed for quite some time (at least, not in the
> zsh 3.0.x sources, I haven't checked 3.1.x).

I haven't changed lete2ctl because as far as I know it still works.  I
shall fix any specific problems reported.

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.

-- 
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.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Directory completion
  1997-09-15  8:05 ` Peter Stephenson
@ 1997-09-15 15:41   ` Peter Stephenson
  1997-09-15 16:11     ` Peter Stephenson
                       ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Peter Stephenson @ 1997-09-15 15:41 UTC (permalink / raw)
  To: Zsh hackers list

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.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Directory completion
  1997-09-15 15:41   ` Directory completion Peter Stephenson
@ 1997-09-15 16:11     ` Peter Stephenson
  1997-09-15 16:31     ` Bruce Stephens
  1997-09-15 16:35     ` Peter Stephenson
  2 siblings, 0 replies; 6+ messages in thread
From: Peter Stephenson @ 1997-09-15 16:11 UTC (permalink / raw)
  To: Zsh hackers list

sorry, minor addition.

*** Doc/Zsh/compctl.yo.dir2	Mon Sep 15 17:05:00 1997
--- Doc/Zsh/compctl.yo	Mon Sep 15 18:09:28 1997
***************
*** 124,130 ****
  item(tt(-f))(
  Filenames and filesystem paths.
  )
! item(tt(-/)){
  Just filesystem paths.
  )
  item(tt(-c))(
--- 124,130 ----
  item(tt(-f))(
  Filenames and filesystem paths.
  )
! item(tt(-/))(
  Just filesystem paths.
  )
  item(tt(-c))(


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Directory completion
  1997-09-15 15:41   ` Directory completion Peter Stephenson
  1997-09-15 16:11     ` Peter Stephenson
@ 1997-09-15 16:31     ` Bruce Stephens
  1997-09-15 16:35     ` Peter Stephenson
  2 siblings, 0 replies; 6+ messages in thread
From: Bruce Stephens @ 1997-09-15 16:31 UTC (permalink / raw)
  To: Zsh hackers list

pws@ifh.de said:
> Any comments (such as `why didn't we do this ages ago'?) 

Yeah.  Why didn't we do this ages ago?

Also, in compctl.yo:

  Filenames and filesystem paths.
+ )
+ item(tt(-/)){
+ Just filesystem paths.
  )


Should be

  Filenames and filesystem paths.
+ )
+ item(tt(-/))(
+ Just filesystem paths.
  )



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Directory completion
  1997-09-15 15:41   ` Directory completion Peter Stephenson
  1997-09-15 16:11     ` Peter Stephenson
  1997-09-15 16:31     ` Bruce Stephens
@ 1997-09-15 16:35     ` Peter Stephenson
  2 siblings, 0 replies; 6+ messages in thread
From: Peter Stephenson @ 1997-09-15 16:35 UTC (permalink / raw)
  To: Peter Stephenson

sorrysorry, second minor addition (for printing out compctl).

*** Src/Zle/compctl.c.dir3	Mon Sep 15 16:36:35 1997
--- Src/Zle/compctl.c	Mon Sep 15 18:30:40 1997
***************
*** 790,796 ****
  printcompctl(char *s, Compctl cc, int printflags)
  {
      Compctl cc2;
!     char *css = "fcqovbAIFpEjrzBRGudeNOZUnQmw";
      char *mss = " pcCwWsSnNmrR";
      unsigned long t = 0x7fffffff;
      unsigned long flags = cc->mask;
--- 790,796 ----
  printcompctl(char *s, Compctl cc, int printflags)
  {
      Compctl cc2;
!     char *css = "fcqovbAIFpEjrzBRGudeNOZUnQmw/";
      char *mss = " pcCwWsSnNmrR";
      unsigned long t = 0x7fffffff;
      unsigned long flags = cc->mask;


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1997-09-15 16:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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   ` Directory completion Peter Stephenson
1997-09-15 16:11     ` Peter Stephenson
1997-09-15 16:31     ` Bruce Stephens
1997-09-15 16:35     ` 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).