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

PATCH: _list_files with quoted characters (etc.)



The file-list style doesn't work when the file name has characters that
have been quoted for inserting into the command line.  The obvious piece
of unquoting appears to fix it.


On a completely separate completion matter, only I'm lazy, there's still
a subtle bug in zsh/complist when scrolling is active (i.e. not all
completions fit on the screen) with lines that wrap (i.e. are larger
than the column width).  It's OK when scrolling forwards (i.e. down,
since across won't be possible in this case), but if you attempt to
scroll back up from the line after the wrapping line, instead of showing
you the wrapping line it repeats the line you were just on.  Then you're
stuck at that point; you can't go up further.

This only happens after you've scrolled the screen---moving down to the
line and then back up without scrolling doesn't trigger it---and then
only when the wrapping line was already on the screen---if you were at the
top of the screen, with the wrapping line off, and move up onto it so
that it appears it's OK.

Given this is the most complicated case---the completions don't fit in
two directions at once---and given it's not that easy to trigger, and
given I've been tinkering with the whole thing without really
understanding it, this could be a whole lot worse.  However, having once
crawled out of the jungle and sat down to sip my G&T on the verandah,
with the distant but sinister sounds of wild animals emerging as
twilight descends, I'm not sure when I'll feel like getting out my
machete again.

O hear the call! Good Hunting, All
    That keep the Jungle Law!

Index: Completion/Unix/Type/_list_files
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_list_files,v
retrieving revision 1.2
diff -u -r1.2 _list_files
--- Completion/Unix/Type/_list_files	12 May 2006 14:58:43 -0000	1.2
+++ Completion/Unix/Type/_list_files	13 Aug 2006 17:25:45 -0000
@@ -8,7 +8,7 @@
 # Sets array listfiles to the display strings and the array
 # listopts appropriately to be added to the compadd command line.
 
-local stat f elt what
+local stat f elt what dir
 local -a stylevals
 integer ok
 
@@ -48,14 +48,17 @@
 
 zmodload -i zsh/stat 2>/dev/null || return 1
 
-for f in ${(P)1}; do
-  if [[ ! -e "${2:+$2/}$f" ]]; then
-    listfiles+=("${2:+$2/}$f")
+dir=${2:+$2/}
+dir=${(Q)dir}
+
+for f in ${(PQ)1}; do
+  if [[ ! -e "$dir$f" ]]; then
+    listfiles+=("$dir$f")
     continue
   fi
 
   # Borrowed from Functions/Example/zls
-  stat -s -H stat -F "%b %e %H:%M" - "${2:+$2/}$f" >/dev/null 2>&1
+  stat -s -H stat -F "%b %e %H:%M" - "$dir$f" >/dev/null 2>&1
 
   listfiles+=("$stat[mode] ${(l:3:)stat[nlink]} ${(r:8:)stat[uid]} \
  ${(r:8:)stat[gid]} ${(l:8:)stat[size]} $stat[mtime] $f")

-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



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