zsh-workers
 help / color / mirror / code / Atom feed
From: "Jörg Sommer" <joerg@alea.gnuu.de>
To: zsh-workers@sunsite.dk
Cc: "Jörg Sommer" <joerg@alea.gnuu.de>
Subject: [PATCH 2/2] Use _multi_parts for scp remote file completion and complete abbrevs
Date: Mon, 13 Oct 2008 19:19:34 +0200	[thread overview]
Message-ID: <1223918374-21544-2-git-send-email-joerg@alea.gnuu.de> (raw)
In-Reply-To: <1223918374-21544-1-git-send-email-joerg@alea.gnuu.de>

This patches uses the function _multi_parts to simplify the code. This
has the drawbacks that:
• The completion description doesn't contain the file type anymore, i.e.
  you don't get the suffixes @, |, * and =.

• The directory separator / isn't automaticly removed from the end, if
  you insert a space.

With _multi_parts it's easier to do completion of abbreviated path like
/u/s/d/zsh. So do it.
---
 Completion/Unix/Command/_ssh |   27 +++++----------------------
 1 files changed, 5 insertions(+), 22 deletions(-)

diff --git a/Completion/Unix/Command/_ssh b/Completion/Unix/Command/_ssh
index 293732c..1ad22f8 100644
--- a/Completion/Unix/Command/_ssh
+++ b/Completion/Unix/Command/_ssh
@@ -2,32 +2,15 @@
 
 _remote_files () {
   # There should be coloring based on all the different ls -F classifiers.
-  local expl rempat remfiles remdispf remdispd args suf ret=1
+  local expl rempat remfiles args
 
   if zstyle -T ":completion:${curcontext}:files" remote-access; then
     zparseopts -D -E -a args p: 1 2 4 6 F:
-    if [[ -z $QIPREFIX ]]
-    then rempat="${PREFIX%%[^./][^/]#}\*"
-    else rempat="${(q)PREFIX%%[^./][^/]#}\*"
-    fi
-    remfiles=(${(M)${(f)"$(_call_program files ssh -o BatchMode=yes $args -a -x ${IPREFIX%:} ls -d1FL "$rempat" 2>/dev/null)"}%%[^/]#(|/)})
-    compset -P '*/'
-    compset -S '/*' || suf='remote file'
-
-    remdispf=(${remfiles:#*/})
-    remdispd=(${(M)remfiles:#*/})
+    rempat="${(q)PREFIX//\//*/}\*"
+    [[ $PREFIX = (.|..|)/* ]] && rempat=${PREFIX%%/*}/${rempat#*/}
+    remfiles=(${(f)"$(_call_program files ssh -o BatchMode=yes $args -a -x ${IPREFIX%:} ls -d1FL "$rempat" 2>/dev/null)"%[*=@|]})
 
-    _tags files
-    while _tags; do
-      while _next_label files expl ${suf:-remote directory}; do
-        [[ -n $suf ]] && compadd "$@" "$expl[@]" -d remdispf \
-	    ${(q)remdispf%[*=@|]} && ret=0 
-	compadd ${suf:+-S/} "$@" "$expl[@]" -d remdispd \
-	    ${(q)remdispd%/} && ret=0
-      done
-      (( ret )) || return 0
-    done
-    return ret
+    _wanted files expl 'remote file' _multi_parts $@ -- / remfiles
   else
     _message -e remote-files 'remote file'
   fi
-- 
1.6.0.2


  reply	other threads:[~2008-10-13 22:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-13 17:19 [PATCH 1/2] Run ssh in batch mode Jörg Sommer
2008-10-13 17:19 ` Jörg Sommer [this message]
2008-10-14  4:26   ` [PATCH 2/2] Use _multi_parts for scp remote file completion and complete abbrevs Bart Schaefer

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=1223918374-21544-2-git-send-email-joerg@alea.gnuu.de \
    --to=joerg@alea.gnuu.de \
    --cc=zsh-workers@sunsite.dk \
    /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).