zsh-users
 help / color / mirror / code / Atom feed
* Re: autocompletion of file url's
  2006-08-02 21:57 autocompletion of file url's Nathan Haigh
@ 2006-08-02 21:34 ` Peter Stephenson
  2006-08-03  9:29   ` Nathan Haigh
  0 siblings, 1 reply; 8+ messages in thread
From: Peter Stephenson @ 2006-08-02 21:34 UTC (permalink / raw)
  To: zsh-users

On Wed, 02 Aug 2006 22:57:51 +0100
Nathan Haigh <n.haigh@sheffield.ac.uk> wrote:
> I've started using subversion a bit recently and it annoys the hell out
> of me when you have to specify repositories etc with file urls since
> autocompletion doesn't work. e.g.
> 
> svn import tmp/myproject file:///path/to/my/svn/repo

It looks like the completion function is still not all that
sophisticated, so presumably no subversion user up to now has got to
grips with the nitty gritty.  Here's your chance to become a zsh
completion wizard...

The despatcher for subversion commands doesn't have an explicit entry
for "import", so it tries to synthesize it from the help text and
doesn't get it right.  This adds an explicit entry.  I'm guessing the
first argument will usually be a directory, but that can be changed if
not.  The URL completion for the second argument is standard across the
completion system and should be good enough for your purposes.

Say if you come across any more problems; I only use subversion very
occasionally (and the Perforce completion is a good deal more complete
:-)) but it's an important thing to get right.

I've added matching parentheses to the case statement because they
looked nicer.

Index: Completion/Unix/Command/_subversion
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_subversion,v
retrieving revision 1.19
diff -u -r1.19 _subversion
--- Completion/Unix/Command/_subversion	12 Jul 2006 02:40:54 -0000	1.19
+++ Completion/Unix/Command/_subversion	2 Aug 2006 21:33:21 -0000
@@ -34,32 +34,38 @@
         )
 
         case $cmd in;
-          add)
+          (add)
             args+=(
               '*:file:_files -g "*(^e:_svn_controlled:)"'
             )
           ;;
-          commit)
+          (commit)
             args+=(
               '*:file:_files -g "*(e:_svn_status:)"'
             )
           ;;
-          delete)
+          (delete)
             args+=(
               '*:file:_files -g ".svn(/e:_svn_deletedfiles:)"'
             )
           ;;
-          diff)
+          (diff)
             args+=(
 	      '*: : _alternative "files:file:_files -g \*\(e:_svn_status:\)" "urls:URL:_svn_urls"'
 	    )
           ;;
-          help)
+          (help)
             args+=(
               '*::sub command:_svn_commands'
             )
+	  ;;
+	  (import)
+	    args+=(
+		'1:project directory:_files -/'
+		'2:import location: _alternative "files:file:_files" "urls:URL:_svn_urls"'
+	    )
           ;;
-          log)
+          (log)
             args+=(
               '1: : _alternative "files:file:_files -g \*\(e:_svn_controlled:\)" "urls:URL:_svn_urls"'
 	      '*:file:_files -g "*(e:_svn_controlled:)"'
@@ -72,17 +78,17 @@
 	    '*:path or url: _alternative "files:file:_files" "urls:URL:_svn_urls"'
 	    )
 	  ;;
-          resolved)
+          (resolved)
             args+=(
               '*:file:_files -g "*(e:_svn_conflicts:)"'
             )
           ;;
-          revert)
+          (revert)
             args+=(
               '*:file:_files -g "(.svn|*)(/e:_svn_deletedfiles:,e:_svn_status:)"'
             )
           ;;
-          *)
+          (*)
             case $usage in
               *(SRC|DST|TARGET|URL*PATH)*)
                 args+=(

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


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

* autocompletion of file url's
@ 2006-08-02 21:57 Nathan Haigh
  2006-08-02 21:34 ` Peter Stephenson
  0 siblings, 1 reply; 8+ messages in thread
From: Nathan Haigh @ 2006-08-02 21:57 UTC (permalink / raw)
  To: zsh-users

I've started using subversion a bit recently and it annoys the hell out
of me when you have to specify repositories etc with file urls since
autocompletion doesn't work. e.g.

svn import tmp/myproject file:///path/to/my/svn/repo

i'd like to be able to type:

svn import tmp/myproject file:///p<tab>
to autocomplete to:
svn import tmp/myproject file:///path

and so on like this:

svn import tmp/myproject file:///path/t<tab>
completes to:
svn import tmp/myproject file:///path/to


I have no idea where to start with zshcompsys and writing
commands/functions to my .zshrc file, so any help would be much appreciated.

Kind regards
Nathan


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

* Re: autocompletion of file url's
  2006-08-03  9:29   ` Nathan Haigh
@ 2006-08-03  9:16     ` Peter Stephenson
  2006-08-03 10:09     ` Nathan Haigh
  2006-08-03 12:34     ` Clint Adams
  2 siblings, 0 replies; 8+ messages in thread
From: Peter Stephenson @ 2006-08-03  9:16 UTC (permalink / raw)
  To: zsh-users

Nathan Haigh <n.haigh@sheffield.ac.uk> wrote:
> This makes it sound like there are zsh functions already in place for
> subversion, is this correct? If so, where can i find them and how do i set
> my shell up to use them as i'm pretty sure they are currently not in use on
> my debian machine.

See the zshcompsys manual page.  The simple way to start is
"autoload -U compinit; compinit".  The patch I posted is for the lastest
version of zsh; I've committed a change to the 4.2 branch to the archive.
You probably need at least 4.2.something for any half-way reasonable subversion
completion.

> I assume you are talking about zsh functions for subversion command
> autocompletion here? e.g. "svn che<tab>" completes to "svn checkout" -
> again, i don't think i currently have this working - how do i do this?

Once the system is installed as above, it will find completions for
subversion automatically.

> Do you mean generic URL completion for things like "file:///p<tab>"
> should already work? If so, it is not in my case - again, how can i get
> it working?

Same answer.  There's just the single step for activating the entire
system.  There are lots of configuration options using "zstyle", however.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php


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

* Re: autocompletion of file url's
  2006-08-03 10:09     ` Nathan Haigh
@ 2006-08-03  9:21       ` Peter Stephenson
  2006-08-06  3:21       ` Thor Andreassen
  1 sibling, 0 replies; 8+ messages in thread
From: Peter Stephenson @ 2006-08-03  9:21 UTC (permalink / raw)
  To: zsh-users

Nathan Haigh <n.haigh@sheffield.ac.uk> wrote:
> Replying to my own posts! :o)
> 
> I have made some progress. I commented out 2 lines at the start of my
> .zshrc file that were not in the .zshrc file on my works machine. These
> were:
> autoload -U compinit
> compinit

That's the wrong way to do it.  You're now going back to the old
"compctl"-based completion.  That has no subversion completion built into
it and you will be picking up whatever compctl instructions are around on
your system.  It's much harder to extend and in particular you're unlikely
ever to get URLs working properly.

Keep the lines above and check you have some version of zsh 4.2 or higher.
After running those lines, "print $_comps[svn]" should output
"_subversion".  That's the completion function I patched yesterday.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php


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

* Re: autocompletion of file url's
  2006-08-02 21:34 ` Peter Stephenson
@ 2006-08-03  9:29   ` Nathan Haigh
  2006-08-03  9:16     ` Peter Stephenson
                       ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Nathan Haigh @ 2006-08-03  9:29 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-users

[-- Attachment #1: Type: text/html, Size: 6106 bytes --]

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

* Re: autocompletion of file url's
  2006-08-03  9:29   ` Nathan Haigh
  2006-08-03  9:16     ` Peter Stephenson
@ 2006-08-03 10:09     ` Nathan Haigh
  2006-08-03  9:21       ` Peter Stephenson
  2006-08-06  3:21       ` Thor Andreassen
  2006-08-03 12:34     ` Clint Adams
  2 siblings, 2 replies; 8+ messages in thread
From: Nathan Haigh @ 2006-08-03 10:09 UTC (permalink / raw)
  Cc: Peter Stephenson, zsh-users

[-- Attachment #1: Type: text/html, Size: 7377 bytes --]

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

* Re: autocompletion of file url's
  2006-08-03  9:29   ` Nathan Haigh
  2006-08-03  9:16     ` Peter Stephenson
  2006-08-03 10:09     ` Nathan Haigh
@ 2006-08-03 12:34     ` Clint Adams
  2 siblings, 0 replies; 8+ messages in thread
From: Clint Adams @ 2006-08-03 12:34 UTC (permalink / raw)
  To: Nathan Haigh, zsh-users

> When i said "I have no idea where to start" i really meant it!
> Therefore i have a few questions...see my comments within your reply.<br>
> FYI: i have a debian system with zsh v4.2.5-7 (from a deb package)
> installed....in the meantime i'll update this to v4.3.2 available via
> the zsh website.<br>

http://www.backports.org/debian/pool/main/z/zsh/


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

* Re: autocompletion of file url's
  2006-08-03 10:09     ` Nathan Haigh
  2006-08-03  9:21       ` Peter Stephenson
@ 2006-08-06  3:21       ` Thor Andreassen
  1 sibling, 0 replies; 8+ messages in thread
From: Thor Andreassen @ 2006-08-06  3:21 UTC (permalink / raw)
  To: zsh-users

On Thu, Aug 03, 2006 at 11:09:46AM +0100, Nathan Haigh wrote:
[...]
> However, I'm experiencing 1 little hiccup: having the 2 line above
> uncommented seem to stop a command working which&nbsp; allow autocompletion
> to be a little more forgiving with regards to case:<br>
> compctl -M '' 'm:{_a-z-}={-A-Z_}'<br>

You should be able to use this instead:

zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'

[...]

Please refrain from sending html mails.

-- 
with kind regards
Thor Andreassen


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

end of thread, other threads:[~2006-08-06  3:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-02 21:57 autocompletion of file url's Nathan Haigh
2006-08-02 21:34 ` Peter Stephenson
2006-08-03  9:29   ` Nathan Haigh
2006-08-03  9:16     ` Peter Stephenson
2006-08-03 10:09     ` Nathan Haigh
2006-08-03  9:21       ` Peter Stephenson
2006-08-06  3:21       ` Thor Andreassen
2006-08-03 12:34     ` Clint Adams

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