zsh-workers
 help / color / mirror / code / Atom feed
* Re: Buglet in zsh perforce completion function
       [not found] <C28AFFCD.FC29%ken.williams@thomson.com>
@ 2007-06-05 18:12 ` Peter Stephenson
  2007-06-10  1:59   ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Stephenson @ 2007-06-05 18:12 UTC (permalink / raw)
  To: Zsh hackers list; +Cc: Ken Williams

I got this bug report...

Ken Williams wrote:
> I recently switched to zsh so that I could use your fantastic _perforce
> completion function. =)  I found a small bug in it that I'm not sure how to
> rectify, but hopefully you will.
> 
> When I'm completing a 'p4 diff -se' command, hitting <tab> can erase part of
> the argument I'm typing, which is a drag if it's a long one.
> 
> For example, here's a sequence I type:
> 
>    p4 diff -se data/w
> 
> Type <tab>, completed to:
>    p4 diff -se data/workflow/
> 
> Type <tab> again, erased to:
>    p4 diff -se data
> 
> Thereafter, if I bounce on the <tab> key it toggles between adding &
> subtracting a slash after the "data" word.

Although I don't get quite the same behaviour (probably due to options),
I can see the / being removed and put back and no completion in the
directory being added.  This boils down to a bug with the following code:

  _tst1() {
      local dir=${PREFIX%%[^/]#}
      # The details of this don't matter much, only
      # the fact that it adds a completion with ... after the
      # directory.
      compadd -J subdirs -p $dir -W $dir ...
  }
  _tst() { _alternative "files:file:_path_files" "dots:dots:_tst1"; }
  compdef _tst tst

Now completing after "tst" exhibits the same symptoms.  I hadn't noticed
because it's suppressed by some option I'm using, I think to do with
tag grouping (but simply putting the subdirs in another group doesn't
work, since that's what I've done in _tst1).

Before I simply try to work round this, does anyone have the first
clue what might be going on in the completion system to cause this?

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

To get further information regarding CSR, please visit our Investor Relations page at http://ir.csr.com/csr/about/overview


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

* Re: Buglet in zsh perforce completion function
  2007-06-05 18:12 ` Buglet in zsh perforce completion function Peter Stephenson
@ 2007-06-10  1:59   ` Bart Schaefer
  2007-06-10  8:19     ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2007-06-10  1:59 UTC (permalink / raw)
  To: Zsh hackers list

On Jun 5,  7:12pm, Peter Stephenson wrote:
}
}   _tst() { _alternative "files:file:_path_files" "dots:dots:_tst1"; }
}   compdef _tst tst
} 
} Before I simply try to work round this, does anyone have the first
} clue what might be going on in the completion system to cause this?

Not precisely, but note this (especially the last sentence):

    -W FILE-PREFIX
          This string is a pathname that will be prepended to each of
          the matches formed by the given WORDS together with any
          prefix specified by the -p option to form a complete filename
          for testing.  Hence it is only useful if combined with the -f
          flag, as the tests will not otherwise be performed.

There isn't any -f option in your compadd, so the -W option is just
confusing.  Also you've said that -p and -W are the same string, which
by my reading means that if there *were* a -f option it would test for
the file "$dir/$dir/..." which can't possibly be what you mean.


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

* Re: Buglet in zsh perforce completion function
  2007-06-10  1:59   ` Bart Schaefer
@ 2007-06-10  8:19     ` Bart Schaefer
  2007-06-11  9:03       ` Peter Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2007-06-10  8:19 UTC (permalink / raw)
  To: Zsh hackers list

On Jun 9,  6:59pm, Bart Schaefer wrote:
}
}     -W FILE-PREFIX
}           This string is a pathname that will be prepended to each of
}           the matches formed by the given WORDS together with any
}           prefix specified by the -p option to form a complete filename
}           for testing.  Hence it is only useful if combined with the -f
}           flag, as the tests will not otherwise be performed.
} 
} There isn't any -f option in your compadd, so the -W option is just
} confusing.

Ignore that, I misread "if combined" as "unless combined".  I've had a bad
cold for the last few days and probably shouldn't even be trying to think
about stuff like this.  This part, though ...

} Also you've said that -p and -W are the same string, which
} by my reading means [...] it would test for
} the file "$dir/$dir/..." which can't possibly be what you mean.

... still stands.


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

* Re: Buglet in zsh perforce completion function
  2007-06-10  8:19     ` Bart Schaefer
@ 2007-06-11  9:03       ` Peter Stephenson
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Stephenson @ 2007-06-11  9:03 UTC (permalink / raw)
  To: Zsh hackers list

On Sun, 10 Jun 2007 01:19:09 -0700
Bart Schaefer <schaefer@brasslantern.com> wrote:
> } Also you've said that -p and -W are the same string, which
> } by my reading means [...] it would test for
> } the file "$dir/$dir/..." which can't possibly be what you mean.
> 
> ... still stands.

I think they do different things, since normal file completion uses
this form, at least in the context in question:

compadd -Qf -J files -X 'Completing file' -F _comp_ignore -p \
macrame/ -W macrame/ -R _perforce_file_suffix -M 'r:|/=* r:|=*' -a tmp1

However, I'm just going to avoid the problem by commenting out the
code that's causing it, which doesn't do very much.  It ought to be
possible to replace it using fake or fake-files, but currently the tags in
_perforce aren't helpful enough.

Index: Completion/Unix/Command/_perforce
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_perforce,v
retrieving revision 1.36
diff -u -r1.36 _perforce
--- Completion/Unix/Command/_perforce	28 Nov 2006 21:57:28 -0000	1.36
+++ Completion/Unix/Command/_perforce	11 Jun 2007 08:59:59 -0000
@@ -858,14 +858,20 @@
 }
 
 
-(( $+functions[_perforce_subdirs] )) ||
-_perforce_subdirs() {
-  # This has no other function than to offer to add the `...' used
-  # by Perforce to indicate a recursive search of directories.
-  # Bit pathetic, really.
-  compset -P '*/'
-  compadd "$@" '...'
-}
+# This has no other function than to offer to add the `...' used
+# by Perforce to indicate a recursive search of directories.
+# Bit pathetic, really.
+#
+# This has been causing odd effects with prefixes so is turned off.
+#(( $+functions[_perforce_subdirs] )) ||
+#_perforce_subdirs() {
+#  if [[ $PREFIX = */* ]]; then
+#    local dir=${PREFIX%%[^/]#}
+#    compadd "$@" -J subdirs -p $dir ...
+#  else
+#    compadd "$@" -J subdirs ...
+#  fi
+#}
 
 
 (( $+functions[_perforce_depot_dirs] )) ||
@@ -1076,7 +1082,8 @@
       altfiles+=("client-dirs:client directory:_perforce_client_dirs")
     fi
     altfiles+=("depot-dirs:directory in depot:_perforce_depot_dirs"
-      "subdirs:subdirectory search:_perforce_subdirs")
+#      "subdirs:subdirectory search:_perforce_subdirs"
+    )
     _alternative $altfiles
   elif [[ -n $unmaintained && -z $dodirs ]]; then
     # a la _cvs_nonentried_files: directories are never maintained,
@@ -1113,7 +1120,7 @@
       altfiles+=("$type-files:$type file:_perforce_${type}_files")
     done
 
-    altfiles+=("subdirs:subdirectory search:_perforce_subdirs")
+#    altfiles+=("subdirs:subdirectory search:_perforce_subdirs")
     if zstyle -t ":completion:${curcontext}:" depot-files; then
       altfiles+=("depot-dirs:directory in depot:_perforce_depot_dirs")
     else
@@ -1126,13 +1133,15 @@
       altfiles+=("depot-files:file in depot:_perforce_depot_files")
     fi
     altfiles+=("depot-dirs:directory in depot:_perforce_depot_dirs"
-      "subdirs:subdirectory search:_perforce_subdirs")
+#      "subdirs:subdirectory search:_perforce_subdirs"
+    )
     _alternative $altfiles
   else
     # Look locally.
-    _alternative \
-      "files:file:_path_files -R _perforce_file_suffix $dodirs" \
-      "subdirs:subdirectory search:_perforce_subdirs"
+#   _alternative \
+#      "files:file:_path_files -R _perforce_file_suffix $dodirs" \
+#      "subdirs:subdirectory search:_perforce_subdirs"
+    _path_files -R _perforce_file_suffix $dodirs
   fi
 }
 


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

To get further information regarding CSR, please visit our Investor Relations page at http://ir.csr.com/csr/about/overview


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

end of thread, other threads:[~2007-06-11  9:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <C28AFFCD.FC29%ken.williams@thomson.com>
2007-06-05 18:12 ` Buglet in zsh perforce completion function Peter Stephenson
2007-06-10  1:59   ` Bart Schaefer
2007-06-10  8:19     ` Bart Schaefer
2007-06-11  9:03       ` Peter Stephenson

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