zsh-workers
 help / color / mirror / code / Atom feed
* Re: PATCH: 3.1.5-pws-8: using pattern completions
@ 1999-02-19 11:46 Sven Wischnowsky
  0 siblings, 0 replies; 10+ messages in thread
From: Sven Wischnowsky @ 1999-02-19 11:46 UTC (permalink / raw)
  To: zsh-workers


Peter Stephenson wrote:

> I wrote:
> > Now, can anyone tell me how to avoid getting a default completion list for
> > the pattern completions as well?  This is rather crucial since I'm trying
> > to get all zf* files to use zftp completion, and I don't want a side dish
> > of local filenames with every order.
> 
> Just thinking: suppose we had a convention where if $COMPSKIP was non-empty
> at any stage, the driver functions (principally __main_complete and
> __normal) would stop generating matches at that point, unset COMPSKIP, and
> return?  That would act like -tn with ordinary compctl's.

Yes, using a parameter for this was what I thought about, too.

> Btw, would it be better to rename AUTODUMP to COMPAUTODUMP to have a
> consistent prefix?

I'd like to remove that parameter anyway: let `init' accept an options 
(-d or so) to enable auto-dumping. It's used only in `init'
anyway. And while I'm at it: I'd like to make `dump' write into a file 
automatically (let it use COMPDUMP, too, with the usual default), so
that it is even easier to make dumps in-between (once we have changed
the example code so that this is possible).

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


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

* Re: PATCH: 3.1.5-pws-8: using pattern completions
@ 1999-02-22 14:07 Sven Wischnowsky
  0 siblings, 0 replies; 10+ messages in thread
From: Sven Wischnowsky @ 1999-02-22 14:07 UTC (permalink / raw)
  To: zsh-workers


Peter Stephenson wrote:

> I wrote:
> > I've just remembered this is what returning 1 from a function does.  You
> > can ignore all my other chatter on the subject.
> 
> I sent this on Friday, as you can see for the date... that's why it doesn't
> make sense any more.  Something's been queueing mail.  (The $COMPSKIP
> mechanism is now part of pws-9.)

Sorry, sorry, sorry... I saw that it is in pws-9 and was very
irritated by this mail ;-)

Three days from Italy to Denmark, whew, snail mail could be faster.

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


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

* Re: PATCH: 3.1.5-pws-8: using pattern completions
@ 1999-02-22 13:44 Sven Wischnowsky
  0 siblings, 0 replies; 10+ messages in thread
From: Sven Wischnowsky @ 1999-02-22 13:44 UTC (permalink / raw)
  To: zsh-workers


Peter Stephenson wrote:

> Peter Stephenson wrote:
> > Now, can anyone tell me how to avoid getting a default completion list for
> > the pattern completions as well?
> 
> I've just remembered this is what returning 1 from a function does.  You
> can ignore all my other chatter on the subject.

I already answered this and in the new code this is done by setting
COMPSKIP (to anything).

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


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

* Re: PATCH: 3.1.5-pws-8: using pattern completions
  1999-02-19 10:33 ` Peter Stephenson
@ 1999-02-22 13:28   ` Peter Stephenson
  0 siblings, 0 replies; 10+ messages in thread
From: Peter Stephenson @ 1999-02-22 13:28 UTC (permalink / raw)
  To: Zsh hackers list

I wrote:
> I've just remembered this is what returning 1 from a function does.  You
> can ignore all my other chatter on the subject.

I sent this on Friday, as you can see for the date... that's why it doesn't
make sense any more.  Something's been queueing mail.  (The $COMPSKIP
mechanism is now part of pws-9.)

-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


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

* Re: PATCH: 3.1.5-pws-8: using pattern completions
@ 1999-02-22  7:51 Sven Wischnowsky
  0 siblings, 0 replies; 10+ messages in thread
From: Sven Wischnowsky @ 1999-02-22  7:51 UTC (permalink / raw)
  To: zsh-workers


Peter Stephenson wrote:

> Sven Wischnowsky wrote:
> > - Due to getting the patterns automatically from the files they are
> >   not sorted. This may be an argument in favor of the simplified
> >   processing I used in the `Comp' example directory.
> 
> But isn't that simply because there's now no way to handle patterns?  That
> doesn't seem to me an advantage.

Actually that version just didn't fill the patcomps-array
automatically (it filled none of the arrays automatically).

But I didn't want to support that version too much anyway, it was just 
a hack done over the weekend, to see if I have some ideas that could
be merged with the old code (as you already said). I sent it to the
list only to see if some of you have ideas for improving the
completion code.

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


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

* Re: PATCH: 3.1.5-pws-8: using pattern completions
  1999-02-19 11:12 Sven Wischnowsky
@ 1999-02-19 14:53 ` Peter Stephenson
  0 siblings, 0 replies; 10+ messages in thread
From: Peter Stephenson @ 1999-02-19 14:53 UTC (permalink / raw)
  To: zsh-workers

Sven Wischnowsky wrote:
> - Due to getting the patterns automatically from the files they are
>   not sorted. This may be an argument in favor of the simplified
>   processing I used in the `Comp' example directory.

But isn't that simply because there's now no way to handle patterns?  That
doesn't seem to me an advantage.

I don't like Functions/Comp as it stands, because there's no way of
automatically defining the relationship between a $COMMAND and a
__function, so I haven't tested it out properly.  I very much prefer a
modular system, which can handle one file per command (or even per suite of
commands), otherwise it makes altering the system and tracking what's going
on just too difficult.  This is for me one of the major advantages of the
new completion system: a single file can replace a ragbag of
initialisations and functions.  I'm quite happy with having some notion of
context built in alongside this.  We already have things a bit like that
with helpers like __files providing common completions for particular
contexts.

> - We probably should also completely remove the completion-array-handling.
>   This would make the code much cleaner, would allow us to get rid of
>   the callcomplete-trampoline, and would allow us to call dump anytime.

Yes, I was wondering about this.  Having a lot of autoloaded functions just
call complist isn't so much worse than than having all the baggage for
handling variables, and this time the simplification would certainly make
the interface no less powerful.  Also, we keep particular completions
within the functions namespace and avoid the variables namespace except for
special usage.  So I'm in favour.  I'll put the new version (which has now
arrived) in pws-9.  The directory will still be Functions/Completion .

-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


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

* Re: PATCH: 3.1.5-pws-8: using pattern completions
@ 1999-02-19 11:12 Sven Wischnowsky
  1999-02-19 14:53 ` Peter Stephenson
  0 siblings, 1 reply; 10+ messages in thread
From: Sven Wischnowsky @ 1999-02-19 11:12 UTC (permalink / raw)
  To: zsh-workers


Peter Stephenson wrote:

> Unless I'm missing a patch or two, pattern completions aren't handled
> properly.  They work rather differently, so it's necessary to pass extra
> arguments to callcomplete.  Possibly these could be passed anyway, saving
> an array look-up in most cases.

There are two more problems: when dumpin patcomps we need to make sure 
the elements are not split (they contain at least one space) and the
pattern-function files should not quote the patterns.

> Now, can anyone tell me how to avoid getting a default completion list for
> the pattern completions as well?  This is rather crucial since I'm trying
> to get all zf* files to use zftp completion, and I don't want a side dish
> of local filenames with every order.

It's in the `|| return 1'. If a pattern function returns non-zero, the 
other patterns and the completion for the command are not tried.

A few open questions:

- The return non-zero convention is intended as a replacement for
  `compctl -t'. I didn't document it because I'm not sure if this is
  the right way to do it.
- Due to getting the patterns automatically from the files they are
  not sorted. This may be an argument in favor of the simplified
  processing I used in the `Comp' example directory.
- We probably should also completely remove the completion-array-handling.
  This would make the code much cleaner, would allow us to get rid of
  the callcomplete-trampoline, and would allow us to call dump anytime.

(I'd like to clean up the whole example code, anyway: use only one
leading underscore, but use it for all functions and aliases, add the
`__if' stuff I described yesterday, remove the aliases, etc. Dunno if
I find the time to do this today, though.)

Bye
 Sven

diff -u of/Completion/__x_options Functions/Completion/__x_options
--- of/Completion/__x_options	Fri Feb 19 12:01:50 1999
+++ Functions/Completion/__x_options	Fri Feb 19 11:28:51 1999
@@ -1,4 +1,4 @@
-#pattern-function '*/X11/*'
+#pattern-function */X11/*
 
 # A simple pattern completion, just as an example.
 
diff -u of/Completion/dump Functions/Completion/dump
--- of/Completion/dump	Fri Feb 19 11:19:21 1999
+++ Functions/Completion/dump	Fri Feb 19 11:33:28 1999
@@ -33,7 +33,7 @@
 
 if (( $#patcomps )); then
   print "\npatcomps=("
-  for __d_f in $patcomps; do
+  for __d_f in "$patcomps[@]"; do
     print -r - "'${__d_f//\'/'\\''}'"
   done
   print ")"

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


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

* Re: PATCH: 3.1.5-pws-8: using pattern completions
  1999-02-19  9:58 Peter Stephenson
  1999-02-19 10:27 ` Peter Stephenson
@ 1999-02-19 10:33 ` Peter Stephenson
  1999-02-22 13:28   ` Peter Stephenson
  1 sibling, 1 reply; 10+ messages in thread
From: Peter Stephenson @ 1999-02-19 10:33 UTC (permalink / raw)
  To: Zsh hackers list

Peter Stephenson wrote:
> Now, can anyone tell me how to avoid getting a default completion list for
> the pattern completions as well?

I've just remembered this is what returning 1 from a function does.  You
can ignore all my other chatter on the subject.

-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


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

* Re: PATCH: 3.1.5-pws-8: using pattern completions
  1999-02-19  9:58 Peter Stephenson
@ 1999-02-19 10:27 ` Peter Stephenson
  1999-02-19 10:33 ` Peter Stephenson
  1 sibling, 0 replies; 10+ messages in thread
From: Peter Stephenson @ 1999-02-19 10:27 UTC (permalink / raw)
  To: Zsh hackers list

I wrote:
> Now, can anyone tell me how to avoid getting a default completion list for
> the pattern completions as well?  This is rather crucial since I'm trying
> to get all zf* files to use zftp completion, and I don't want a side dish
> of local filenames with every order.

Just thinking: suppose we had a convention where if $COMPSKIP was non-empty
at any stage, the driver functions (principally __main_complete and
__normal) would stop generating matches at that point, unset COMPSKIP, and
return?  That would act like -tn with ordinary compctl's.

Btw, would it be better to rename AUTODUMP to COMPAUTODUMP to have a
consistent prefix?

-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


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

* PATCH: 3.1.5-pws-8: using pattern completions
@ 1999-02-19  9:58 Peter Stephenson
  1999-02-19 10:27 ` Peter Stephenson
  1999-02-19 10:33 ` Peter Stephenson
  0 siblings, 2 replies; 10+ messages in thread
From: Peter Stephenson @ 1999-02-19  9:58 UTC (permalink / raw)
  To: Zsh hackers list

Unless I'm missing a patch or two, pattern completions aren't handled
properly.  They work rather differently, so it's necessary to pass extra
arguments to callcomplete.  Possibly these could be passed anyway, saving
an array look-up in most cases.

Now, can anyone tell me how to avoid getting a default completion list for
the pattern completions as well?  This is rather crucial since I'm trying
to get all zf* files to use zftp completion, and I don't want a side dish
of local filenames with every order.

--- Functions/Completion/__normal.pat	Fri Feb 19 10:50:41 1999
+++ Functions/Completion/__normal	Fri Feb 19 10:50:57 1999
@@ -24,11 +24,13 @@
 # See if there are any matching pattern completions.
 
 if (( $#patcomps )); then
+  integer num
   for i in "$patcomps[@]"; do
-    pat="${i% *}"
+    (( num++ ))
+    pat="${i%% *}"
     val="${i#* }"
     if [[ "$cmd1" == $~pat || "$cmd2" == $~pat ]]; then
-      callcomplete patcomps "$pat" "$@" || return 1
+      callcomplete -d "$pat" "$val" patcomps "$num" "$@" || return 1
     fi
   done
 fi
--- Functions/Completion/init.pat	Fri Feb 19 10:50:41 1999
+++ Functions/Completion/init	Fri Feb 19 10:50:57 1999
@@ -175,11 +175,19 @@
 # to the completion function (containing the arguments from the command line).
 
 callcomplete() {
-  local file def
+  local file def pat
 
-  # Get the definition from the array.
-
-  eval "def=\$${1}[${2}]"
+  if [[ $1 = -d ]]; then
+    # We've already got the definition.
+    shift
+    pat=$1
+    shift
+    def=$1
+    shift
+  else
+    # Get the definition from the array.
+    eval "def=\$${1}[${2}]"
+  fi
 
   # If the definition starts with a space then this means that we should
   # source a file to get the definition for an array.
@@ -191,7 +199,11 @@
     file="$def[2,-1]"
     builtin . "$file"
     def="${file:t}"
-    eval "${1}[${2}]=$def"
+    if [[ -n $pat ]]; then
+      eval "${1}[${2}]='$pat $def'"
+    else
+      eval "${1}[${2}]=$def"
+    fi
   fi
 
   # Get rid of the array-name and -index.
@@ -236,7 +248,7 @@
       elif [[ $func = '#pattern-function' ]]; then
 	defpatcomp -a ${__i_file:t} "${__i_line[@]}"
       elif [[ $func = '#pattern-array' ]]; then
-	defcomp " $__i_file" "${__i_line[@]}"
+	defpatcomp " $__i_file" "${__i_line[@]}"
       elif [[ $func = '#key-function' ]]; then
 	defkeycomp -a "${__i_file:t}" "${__i_line[@]}"
       elif [[ $func = '#key-array' ]]; then

-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


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

end of thread, other threads:[~1999-02-22 14:08 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-02-19 11:46 PATCH: 3.1.5-pws-8: using pattern completions Sven Wischnowsky
  -- strict thread matches above, loose matches on Subject: below --
1999-02-22 14:07 Sven Wischnowsky
1999-02-22 13:44 Sven Wischnowsky
1999-02-22  7:51 Sven Wischnowsky
1999-02-19 11:12 Sven Wischnowsky
1999-02-19 14:53 ` Peter Stephenson
1999-02-19  9:58 Peter Stephenson
1999-02-19 10:27 ` Peter Stephenson
1999-02-19 10:33 ` Peter Stephenson
1999-02-22 13:28   ` 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).