Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: Re: pws-10 RE: zsh-3.1.5-pws-9: _path_files and symbolic links



(Phew, I hope I don't have to rewrite all my completions again...
Just have to wait and see if Bart excoriates `compgen'.)

Sven Wischnowsky wrote:
> This uses `compgen' (i.e. the former `complist'), not `_files'. Was
> the reason for this that `_path_files' didn't handle ignored prefixes
> correctly? My big patch made `_path_files' give `IPREFIX' to `compadd' 
> so this should work now.

Not sure if that was part of the problem, but there was an earlier problem,
also now fixed, where _path_files was less than happy about producing only
directories.  Since there's no point in having files other than
directories, I've made it just call _path_files rather than _files.  There
was also a bit of over-compensation in _mh: the perl code to generate
options using the -help output now uses $words instead of backreferences,
which is a little baroque.  Also, there was a bit missing from _zftp.
Finally, while I'm here, I've upgraded _most_recent_file to handle ~'s
properly (that ${.../#.../...} feature is neater than I realised it was
going to be).

Also

> Ah, tricky. The patch below makes path components be left unchanged
> only if the rest of the string would produce a match below that
> directory.

Was that all that needed doing?  I knew about this, but didn't complain
about this because I thought it was a feature which would need a lot of
work to alter.

--- Completion/Builtins/_zftp.bak	Mon Mar  1 13:50:33 1999
+++ Completion/Builtins/_zftp	Mon Mar  1 15:26:08 1999
@@ -15,8 +15,10 @@
       putat get getat append appendat ls dir local remote mkdir rmdir
     return
   fi
+  subcom=$words[2]
+else
+  subcom=$words[1]
 fi
-subcom=$words[2]
 
 case $subcom in
   *(cd|ls|dir))
--- Completion/Commands/_most_recent_file.bak	Mon Mar  1 13:50:34 1999
+++ Completion/Commands/_most_recent_file	Mon Mar  1 15:45:41 1999
@@ -1,4 +1,11 @@
 #defkeycomp complete-word \C-xm
-local file
-compgen -g '*(om[1])'
-(( $#file )) && compadd -f $file
+local file tilde exptilde
+if [[ $PREFIX = \~*/ ]]; then
+  tilde=${PREFIX%%/*}
+  etilde=${~tilde}
+  file=($~PREFIX*$~SUFFIX(om[1]N))
+  file=(${file/#$etilde/$tilde})
+else
+  file=($~PREFIX*$~SUFFIX(om[1]N))
+fi
+(( $#file )) && compadd -f -Q $file
--- Completion/User/_mh.bak	Mon Mar  1 13:50:35 1999
+++ Completion/User/_mh	Mon Mar  1 15:40:59 1999
@@ -1,4 +1,4 @@
-#defcomp folder comp inc mark refile repl scan show next prev rmm pick whom mhn mhpath mhpatch
+#defcomp folder folders comp inc mark refile repl scan show next prev rmm pick whom mhn mhpath
 
 # Completion for all possible MH commands.
 # Alter the following two to your own mh directory and the directory
@@ -17,9 +17,9 @@
   # awk is just too icky to use for this, sorry.  send me one if
   # you come up with it.
   compadd - $($words[1] -help | perl -ne 'if (/^\s*-\(?(\S+)/) {
-    $n = $words[2];
+    $n = $1;
     $n =~ s/\)//g;
-    print $n =~ s/^\[([a-z]+)\]// ? "$n\n${words[2]}$n\n" : "$n\n";
+    print $n =~ s/^\[([a-z]+)\]// ? "$n\n$1$n\n" : "$n\n";
   }')
   return
 elif [[ -iprefix '+' || -iprefix '@' || "$prev" = -draftfolder ]]; then
@@ -33,7 +33,7 @@
   fi
 
   # painless, or what?
-  compgen -W mhpath -/
+  _path_files -W mhpath -/
 elif [[ "$prev" = -(editor|(whatnow|rmm|show|more)proc) ]]; then
   compgen -c
 elif [[ "$prev" = -file ]]; then
@@ -50,7 +50,7 @@
 elif [[ "$prev" = -(no|)cc ]]; then
   compadd all to cc me
 elif [[ "$prev" = -[rw]cache ]]; then
-  compadd  public private never ask
+  compadd public private never ask
 else
   # Generate sequences.
   local foldnam folddir f
@@ -66,7 +66,7 @@
     # leaving foldnam empty works here
   fi
 
-  compgen -s '$(mark $foldnam | awk -F: '\''{ print $1 }'\'')'
-  compadd  reply next cur prev first last all unseen
+  compgen -s '$(mark $foldnam 2>/dev/null | awk -F: '\''{ print $1 }'\'')'
+  compadd reply next cur prev first last all unseen
   compgen -W folddir -g '<->'
 fi

-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy



Messages sorted by: Reverse Date, Date, Thread, Author