zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: partly rewriting alias handling in _git
@ 2008-09-01 18:06 Frank Terbeck
  2008-09-01 18:17 ` Frank Terbeck
  2008-09-01 19:22 ` Clint Adams
  0 siblings, 2 replies; 4+ messages in thread
From: Frank Terbeck @ 2008-09-01 18:06 UTC (permalink / raw)
  To: zsh workers

While the last patch (zw25561) in that field did improve the handling
of git aliases, it also drew my attention to other problems in the
code.

I've been playing with this version for some time and AFAICS it
handles most cases quite well (a lot better than the old one).

Another thing, I didn't address in this patch is this:
    % git c  --some args
           ^- place the cursor here and hit <tab>.

That does not return completions like 'commit'.

If, later in the code (at the end before the last 'case'), you
replace "'*::options:->options' && ret=0" with
        "'*:options:->options' && ret=0", it starts to work.

I'm not sure if I am missing something and the two-colon form was used
on purpose.

Anyway, as for git alias handling:

Index: Completion/Unix/Command/_git
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_git,v
retrieving revision 1.95
diff -u -r1.95 _git
--- Completion/Unix/Command/_git	31 Aug 2008 16:09:08 -0000	1.95
+++ Completion/Unix/Command/_git	1 Sep 2008 18:02:55 -0000
@@ -4285,16 +4285,16 @@
 IFS=$oifs ; unset oifs
 
 if (( CURRENT >= 3 )) && [[ -n ${git_aliases[$words[2]]} ]] ; then
-  local -a tmpwords
-  tmpwords=(${words[1]} ${(z)git_aliases[$words[2]]})
-  if [[ -z "${words[3,-1]}" ]] ; then
-      tmpwords[$(( ${#tmpwords} + 1 ))]=""
-  else
+  local -a tmpwords expalias
+  expalias=(${(z)git_aliases[$words[2]]})
+  tmpwords=(${words[1]} ${expalias})
+  if [[ -n "${words[3,-1]}" ]] ; then
       tmpwords+=(${words[3,-1]})
   fi
+  tmpwords+=('')
+  (( CURRENT += ${#expalias} - 1 ))
   words=("${tmpwords[@]}")
-  (( CURRENT += ${#${(z)git_aliases[$words[2]]}} - 1 ))
-  unset tmpwords
+  unset tmpwords expalias
 fi
 
 if [[ $service == git ]]; then


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

* Re: PATCH: partly rewriting alias handling in _git
  2008-09-01 18:06 PATCH: partly rewriting alias handling in _git Frank Terbeck
@ 2008-09-01 18:17 ` Frank Terbeck
  2008-09-01 19:22 ` Clint Adams
  1 sibling, 0 replies; 4+ messages in thread
From: Frank Terbeck @ 2008-09-01 18:17 UTC (permalink / raw)
  To: zsh workers

Frank Terbeck <ft@bewatermyfriend.org>:
[...]
> If, later in the code (at the end before the last 'case'), you
> replace "'*::options:->options' && ret=0" with
>         "'*:options:->options' && ret=0", it starts to work.
> 
> I'm not sure if I am missing something and the two-colon form was used
> on purpose.

Scratch that. Turns out, the one-colon form doesn't work at all...

Regards, Frank

-- 
In protocol design, perfection has been reached not when there is
nothing left to add, but when there is nothing left to take away.
                                                  -- RFC 1925


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

* Re: PATCH: partly rewriting alias handling in _git
  2008-09-01 18:06 PATCH: partly rewriting alias handling in _git Frank Terbeck
  2008-09-01 18:17 ` Frank Terbeck
@ 2008-09-01 19:22 ` Clint Adams
  2008-09-01 20:03   ` Frank Terbeck
  1 sibling, 1 reply; 4+ messages in thread
From: Clint Adams @ 2008-09-01 19:22 UTC (permalink / raw)
  To: zsh workers

On Mon, Sep 01, 2008 at 08:06:42PM +0200, Frank Terbeck wrote:
>     % git c  --some args
>            ^- place the cursor here and hit <tab>.
> 
> That does not return completions like 'commit'.

Try this.

Index: Completion/Unix/Command/_git
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_git,v
retrieving revision 1.96
diff -u -r1.96 _git
--- Completion/Unix/Command/_git	1 Sep 2008 18:49:33 -0000	1.96
+++ Completion/Unix/Command/_git	1 Sep 2008 19:19:59 -0000
@@ -4307,15 +4307,15 @@
     '(-p --paginate)'{-p,--paginate}'[pipe output into $PAGER]' \
     '--git-dir=-[path to repository]:directory:_directories' \
     '--bare[use $PWD as repository]' \
-    ':command:->command' \
-    '*::options:->options' && ret=0
+    '*::arg:->cmd_or_options' && return
   case $state in
-    (command)
-      __git_aliases_and_commands
-      ;;
-    (options)
-      curcontext="${curcontext%:*:*}:git-$words[1]:"
-      _call_function ret _git-$words[1]
+    (cmd_or_options)
+      if (( CURRENT == 1 )); then
+        __git_aliases_and_commands
+      else
+        curcontext="${curcontext%:*:*}:git-$words[1]:"
+        _call_function ret _git-$words[1]
+      fi
       ;;
   esac
 else


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

* Re: PATCH: partly rewriting alias handling in _git
  2008-09-01 19:22 ` Clint Adams
@ 2008-09-01 20:03   ` Frank Terbeck
  0 siblings, 0 replies; 4+ messages in thread
From: Frank Terbeck @ 2008-09-01 20:03 UTC (permalink / raw)
  To: zsh workers

Clint Adams <clint@zsh.org>:
> On Mon, Sep 01, 2008 at 08:06:42PM +0200, Frank Terbeck wrote:
> >     % git c  --some args
> >            ^- place the cursor here and hit <tab>.
> > 
> > That does not return completions like 'commit'.
> 
> Try this.

Works, thanks.

Regards, Frank

-- 
In protocol design, perfection has been reached not when there is
nothing left to add, but when there is nothing left to take away.
                                                  -- RFC 1925


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

end of thread, other threads:[~2008-09-01 20:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-01 18:06 PATCH: partly rewriting alias handling in _git Frank Terbeck
2008-09-01 18:17 ` Frank Terbeck
2008-09-01 19:22 ` Clint Adams
2008-09-01 20:03   ` Frank Terbeck

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