zsh-workers
 help / color / mirror / code / Atom feed
* Re: PATCH: completions for su and implicit fg/bg
  1999-07-09 10:23 PATCH: completions for su and implicit fg/bg Oliver Kiddle
@ 1999-07-09 10:04 ` Peter Stephenson
  1999-07-09 10:40 ` Andrej Borsenkow
  1 sibling, 0 replies; 16+ messages in thread
From: Peter Stephenson @ 1999-07-09 10:04 UTC (permalink / raw)
  To: Zsh workers

Oliver Kiddle wrote:
> First, is a patch to _first which completes jobs after an initial % on
> the command line.

I think the code in _first was deliberately left commented because it gets
run every time, but the impact of this change is minimal.

> This is useful when foregrounding or backgrounding a
> process without fg/bg. This feature seems to be undocumented actually.

Hmm, I thought it was an option, but it seems it's run unconditionally at
the top of execcmd().  What is an option is AUTO_RESUME.

> I've included a basic completion for the
> common shells which just does the -c option.

It really needs to be told to treat a (possibly quoted) word after -c as a
complete command line.  I've forgotten how to do that.

-- 
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] 16+ messages in thread

* PATCH: completions for su and implicit fg/bg
@ 1999-07-09 10:23 Oliver Kiddle
  1999-07-09 10:04 ` Peter Stephenson
  1999-07-09 10:40 ` Andrej Borsenkow
  0 siblings, 2 replies; 16+ messages in thread
From: Oliver Kiddle @ 1999-07-09 10:23 UTC (permalink / raw)
  To: Zsh workers

First, is a patch to _first which completes jobs after an initial % on
the command line. This is useful when foregrounding or backgrounding a
process without fg/bg. This feature seems to be undocumented actually.
I'll send a patch to the docs unless someone locates it there somewhere
already. Completion of commands where the command will be run should
really quote an initial '%' (or more to the point should preserve a
quote which has been typed). This wouldn't be that easy to do though
because in many other cases when completing command names, an initial
'%' would be totally valid.

The second new completion is for su. Usernames are completed as the
first parameter or second after a -. Next it works out which shell the
specified user has and completes options for that shell. My first
thought was that I'd use something like compgen -l $shell but ofcourse
compgen doesn't support -l. Judging by _find, it seems that _normal is
the way to do this but it would need the shell's name to be on the
command-line. I've got it to work by pulling the relevant parts out of
_normal and roughly repeating it. I didn't bother with the pattern
matching stuff though. A better way would be if _normal took an optional
parameter similar to the parameter to compctl -l. I can make this change
if it is agreed. So that this stuff for completing shell parameters
after su is actually useful, I've included a basic completion for the
common shells which just does the -c option. Note that I've not bothered
to deal with the extra options which GNU su offers because I think they
are all utterly pointless.

Oliver Kiddle

*** Completion/Base/_first.old	Mon Jun 21 08:14:44 1999
--- Completion/Base/_first	Fri Jul  9 10:03:52 1999
***************
*** 61,63 ****
--- 61,68 ----
  #         (( i++ ))
  #       done
  #     fi
+ 
+ # Complete jobs in implicit fg and bg
+ if [[ "$CURRENT" = 1 && "$PREFIX[1]" = "%" ]]; then
+   compgen -j -P '%'
+ fi
*** Completion/User/_su.old	Fri Jul  9 10:25:55 1999
--- Completion/User/_su	Fri Jul  9 10:25:20 1999
***************
*** 0 ****
--- 1,22 ----
+ #compdef su
+ 
+ local shell comp name usr base
+ 
+ [[ $words[2] != - ]]
+ (( base=$?+2 ))
+ 
+ if [[ CURRENT -eq base ]]; then
+   compgen -u && return
+   usr=root
+ elif [[ CURRENT -ge base+1 ]]; then
+   usr=$words[base]
+ else
+   return
+ fi
+ 
+ shell=${"$(egrep "^$usr:" </etc/passwd)"##*:}
+ compset -n $base
+ for name in $shell $shell:t -default-; do
+   comp="$_comps[$name]"
+   [[ ! -z "$comp" ]] && "$comp" && return
+ done  
*** Completion/User/_sh.old	Fri Jul  9 10:25:52 1999
--- Completion/User/_sh	Fri Jul  9 10:25:20 1999
***************
*** 0 ****
--- 1,3 ----
+ #compdef sh ksh bash zsh csh tcsh rc
+ 
+ compset -N '-c' && _normal


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

* RE: PATCH: completions for su and implicit fg/bg
  1999-07-09 10:23 PATCH: completions for su and implicit fg/bg Oliver Kiddle
  1999-07-09 10:04 ` Peter Stephenson
@ 1999-07-09 10:40 ` Andrej Borsenkow
  1 sibling, 0 replies; 16+ messages in thread
From: Andrej Borsenkow @ 1999-07-09 10:40 UTC (permalink / raw)
  To: Oliver Kiddle, Zsh workers

                                  Judging by _find, it seems that _normal is
> the way to do this but it would need the shell's name to be on the
> command-line. I've got it to work by pulling the relevant parts out of
> _normal and roughly repeating it.

Correct me if I'm wrong, but don't you simply need to setup $words and set
CURRENT to reflect the word to complete? Something like

words=(sh $words)
((CURRENT++))
_normal

/andrej


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

* Re: PATCH: completions for su and implicit fg/bg
@ 1999-07-19 13:58 Sven Wischnowsky
  1999-07-19 13:38 ` Peter Stephenson
  0 siblings, 1 reply; 16+ messages in thread
From: Sven Wischnowsky @ 1999-07-19 13:58 UTC (permalink / raw)
  To: zsh-workers


I wrote:

> I wrote:
> 
> > This allows `compset -q' on unquoted words -- almost. There is a
> > problem when the match contains characters that have to be quoted. In
> > such cases the match should be quoted twice (`a b' should be inserted
> > as `a\\\ b'), but currently the completion code is far from being
> > prepared for such double-quoting and I'm seeing to much places where
> > changes are needed for a quick patch.
> 
> I've been thinking some more about this... This can get pretty ugly
> when we have multiple calls to `compset -q' for the same word. In such 
> cases we would have to keep track of the number of calls (the nesting
> level) and then quote the words put into the command line n times. Of
> course the results may become almost unreadable and it would require
> changes in several parts of the code.

I've now spent several days trying to get this right -- and am now
really fed up. My last solution almost worked but still had problems
with, e.g. zsh -c 'zsh -c "zsh -c echo\ <TAB>. Mainly due to the
somewhat weird backslash-in-quotes behavior. Also, I only had this for 
inserting unambiguous matches (do_single()), and the stuff for
unambiguous prefixes is even harder.

So, I *will* some day try to fix this, but I don't think I'll be able
to do this this week and next week I'll be away.

I'll have to find a completely different way for this...

Bye
 Sven


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


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

* Re: PATCH: completions for su and implicit fg/bg
  1999-07-19 13:58 Sven Wischnowsky
@ 1999-07-19 13:38 ` Peter Stephenson
  0 siblings, 0 replies; 16+ messages in thread
From: Peter Stephenson @ 1999-07-19 13:38 UTC (permalink / raw)
  To: zsh-workers

Sven Wischnowsky wrote:
> I've now spent several days trying to get this right -- and am now
> really fed up.

This is why I gave it as an example of things that wouldn't have to be
perfect before 3.1.6.  It works for some pretty complicated cases already,
and frankly anyone expecting it to work any deeper needs to see a
specialist about their spaghetti code problem :-).

-- 
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] 16+ messages in thread

* Re: PATCH: completions for su and implicit fg/bg
@ 1999-07-13  9:02 Sven Wischnowsky
  0 siblings, 0 replies; 16+ messages in thread
From: Sven Wischnowsky @ 1999-07-13  9:02 UTC (permalink / raw)
  To: zsh-workers


Peter Stephenson wrote:

> OK, the next problem seems to be that using ^D removes the quotes, although
> other completion functions don't.  I'm using

Oops. Forgot to restore the command line in two cases where it isn't
expected to change.

Bye
 Sven

diff -u os/Zle/zle_tricky.c Src/Zle/zle_tricky.c
--- os/Zle/zle_tricky.c	Tue Jul 13 10:59:34 1999
+++ Src/Zle/zle_tricky.c	Tue Jul 13 10:59:52 1999
@@ -4380,10 +4380,14 @@
 	}
 	if (comppatmatch && *comppatmatch && comppatmatch != opm)
 	    haspattern = 1;
-	if (!useline && uselist)
+	if (!useline && uselist) {
 	    /* All this and the guy only wants to see the list, sigh. */
+	    cs = 0;
+	    foredel(ll);
+	    inststr(origline);
+	    cs = origcs;
 	    showinglist = -2;
-	else if (useline) {
+	} else if (useline) {
 	    /* We have matches. */
 	    if (nmatches > 1) {
 		/* There is more than one match. */
@@ -4399,9 +4403,13 @@
 		do_single(m->matches[0]);
 		invalidatelist();
 	    }
-	} else
+	} else {
 	    invalidatelist();
-
+	    cs = 0;
+	    foredel(ll);
+	    inststr(origline);
+	    cs = origcs;
+	}
 	/* Print the explanation strings if needed. */
 	if (!showinglist && validlist && usemenu != 2 && nmatches != 1) {
 	    Cmgroup g = amatches;

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


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

* Re: PATCH: completions for su and implicit fg/bg
  1999-07-12 12:11 Sven Wischnowsky
@ 1999-07-12 14:29 ` Peter Stephenson
  0 siblings, 0 replies; 16+ messages in thread
From: Peter Stephenson @ 1999-07-12 14:29 UTC (permalink / raw)
  To: zsh-workers

Sven Wischnowsky wrote:
> Peter Stephenson wrote:
> > Just trying compset -q to enhance completion for *sh -c:

OK, the next problem seems to be that using ^D removes the quotes, although
other completion functions don't.  I'm using

  #compdef sh ksh bash zsh csh tcsh rc

  local cword=

  if (( CURRENT == ${words[(i)-c]} + 1 )); then
    compset -q
    _normal
  fi

and typing
  
  % sh -c 'e^D

but what follows the open quote doesn't seem to matter.

-- 
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] 16+ messages in thread

* Re: PATCH: completions for su and implicit fg/bg
@ 1999-07-12 12:11 Sven Wischnowsky
  1999-07-12 14:29 ` Peter Stephenson
  0 siblings, 1 reply; 16+ messages in thread
From: Sven Wischnowsky @ 1999-07-12 12:11 UTC (permalink / raw)
  To: zsh-workers


Peter Stephenson wrote:

> Just trying compset -q to enhance completion for *sh -c:
> 
>   The word
>   currently being completed is split in separate words at the spaces. The 
>   resulting words are stored in the tt(words) array, and tt(PREFIX),
>   tt(SUFFIX), tt(QIPREFIX), and tt(QISUFFIX) are modified to reflect the 
>   word part that is completed.
> 
> What doesn't seem to get updated is CURRENT, which for consistency ought to
> point into the $words array as modified.

Whoa. Ahem.

This also corrects the test to decide if the ignored prefix/suffix
should be quoted or not.

Bye
 Sven

diff -u os/Zle/zle_tricky.c Src/Zle/zle_tricky.c
--- os/Zle/zle_tricky.c	Fri Jul  9 15:48:20 1999
+++ Src/Zle/zle_tricky.c	Mon Jul 12 14:07:18 1999
@@ -5172,7 +5172,7 @@
 	compisuffix = ztrdup("");
 	zsfree(compqiprefix);
 	zsfree(compqisuffix);
-	if (instring) {
+	if (ois) {
 	    compqiprefix = qp;
 	    compqisuffix = qs;
 	} else {
@@ -5188,6 +5188,7 @@
 	    p = compwords[i] = (char *) getdata(n);
 	    untokenize(p);
 	}
+	compcurrent = cur + 1;
 	compwords[i] = NULL;
     }
     autoq = oaq;
diff -u od/Zsh/compwid.yo Doc/Zsh/compwid.yo
--- od/Zsh/compwid.yo	Mon Jul 12 10:21:21 1999
+++ Doc/Zsh/compwid.yo	Mon Jul 12 14:10:11 1999
@@ -622,9 +622,9 @@
 item(tt(-q))(
 The word
 currently being completed is split in separate words at the spaces. The 
-resulting words are stored in the tt(words) array, and tt(PREFIX),
-tt(SUFFIX), tt(QIPREFIX), and tt(QISUFFIX) are modified to reflect the 
-word part that is completed.
+resulting words are stored in the tt(words) array, and tt(CURRENT),
+tt(PREFIX), tt(SUFFIX), tt(QIPREFIX), and tt(QISUFFIX) are modified to
+reflect the word part that is completed.
 )
 enditem()
 

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


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

* Re: PATCH: completions for su and implicit fg/bg
  1999-07-12 10:39 Sven Wischnowsky
@ 1999-07-12 11:27 ` Peter Stephenson
  0 siblings, 0 replies; 16+ messages in thread
From: Peter Stephenson @ 1999-07-12 11:27 UTC (permalink / raw)
  To: zsh-workers

Just trying compset -q to enhance completion for *sh -c:

  The word
  currently being completed is split in separate words at the spaces. The 
  resulting words are stored in the tt(words) array, and tt(PREFIX),
  tt(SUFFIX), tt(QIPREFIX), and tt(QISUFFIX) are modified to reflect the 
  word part that is completed.

What doesn't seem to get updated is CURRENT, which for consistency ought to
point into the $words array as modified.

-- 
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] 16+ messages in thread

* Re: PATCH: completions for su and implicit fg/bg
@ 1999-07-12 10:39 Sven Wischnowsky
  1999-07-12 11:27 ` Peter Stephenson
  0 siblings, 1 reply; 16+ messages in thread
From: Sven Wischnowsky @ 1999-07-12 10:39 UTC (permalink / raw)
  To: zsh-workers


I wrote:

> This allows `compset -q' on unquoted words -- almost. There is a
> problem when the match contains characters that have to be quoted. In
> such cases the match should be quoted twice (`a b' should be inserted
> as `a\\\ b'), but currently the completion code is far from being
> prepared for such double-quoting and I'm seeing to much places where
> changes are needed for a quick patch.

I've been thinking some more about this... This can get pretty ugly
when we have multiple calls to `compset -q' for the same word. In such 
cases we would have to keep track of the number of calls (the nesting
level) and then quote the words put into the command line n times. Of
course the results may become almost unreadable and it would require
changes in several parts of the code.

Hm. Automatically putting such strings in quotes is probably easier
but otherwise not much better. Does anybody see a better solution?
Should we just give up and make `compset -q' work only on quoted
strings again? Any other suggestions?

Bye
 Sven


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


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

* Re: PATCH: completions for su and implicit fg/bg
  1999-07-09 14:47       ` Peter Stephenson
@ 1999-07-09 15:53         ` Oliver Kiddle
  0 siblings, 0 replies; 16+ messages in thread
From: Oliver Kiddle @ 1999-07-09 15:53 UTC (permalink / raw)
  To: zsh-workers

Peter Stephenson wrote:

> You're right, I've removed that, but we need to handle other people's
> passwords better --- I'd be tempted to use perl.

What's wrong with it at the moment other than that it'll need a minor
change for anyone using NIS? I'd prefer to avoid perl if at all possible
because it isn't always installed everywhere and can take a while to
start-up on a slow computer. If you're concerned that egrep may return
more than one match, sed can be used instead.

Oliver Kiddle


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

* Re: PATCH: completions for su and implicit fg/bg
  1999-07-09 13:53     ` Oliver Kiddle
@ 1999-07-09 14:47       ` Peter Stephenson
  1999-07-09 15:53         ` Oliver Kiddle
  0 siblings, 1 reply; 16+ messages in thread
From: Peter Stephenson @ 1999-07-09 14:47 UTC (permalink / raw)
  To: zsh-workers

Oliver Kiddle wrote:
> You don't want to use $SHELL. The command is run using the default shell
> of the user which is su'd to.

You're right, I've removed that, but we need to handle other people's
passwords better --- I'd be tempted to use perl.

> Seeing as it's possible to stick stuff at the beginning of $words it
> isn't essential to allow this to be a parameter. I suppose it will be
> more readable for completions which use it though so is probably worth
> doing. If you want to include it, the single line:
> words=( $@ $words[@] )
> added to the start of _normal should do the trick.

Except the rest of the arguments in _normal are funny.  My brain's not
working well enough to think about the consequences on things like CURRENT,
so I've just left it for the time being.

> P.S. Sorry Peter, you'll get this twice as I accidentally did a Reply
> instead of Replyall and am now resending.

Except it came separately and landed in my standard new mail folder, which
was more interesting.

-- 
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] 16+ messages in thread

* Re: PATCH: completions for su and implicit fg/bg
       [not found]   ` <3785FAFB.3E9FDD41@thoth.u-net.com>
@ 1999-07-09 13:53     ` Oliver Kiddle
  1999-07-09 14:47       ` Peter Stephenson
  0 siblings, 1 reply; 16+ messages in thread
From: Oliver Kiddle @ 1999-07-09 13:53 UTC (permalink / raw)
  To: zsh-workers

Peter Stephenson wrote:
>
> Yes, of course that's the right place.  This patch moves it there.
> Also, the obvious way of getting the shell is from $SHELL, so I added that
> to _su.

You don't want to use $SHELL. The command is run using the default shell
of the user which is su'd to. So if I type su fred -c command, then the
command will be run using fred's default shell. This is why I used
$words[base] to get the username parameter as given to su which it then
looks up in /etc/passwd.

> > And: nothing against giving _normal (an) optional argument(s) that
> > will be put at the front of $words. (_normal is one of the older
>
> Sounds reasonable, but I haven't looked at this.
 
Seeing as it's possible to stick stuff at the beginning of $words it
isn't essential to allow this to be a parameter. I suppose it will be
more readable for completions which use it though so is probably worth
doing. If you want to include it, the single line:
words=( $@ $words[@] )
added to the start of _normal should do the trick. In _su, the for loop
is just replaced by
_normal $shell
Although, you could ditch the shell variable and put the expansion after
_normal. I'll send a patch if it makes it easier.

Oliver Kiddle

P.S. Sorry Peter, you'll get this twice as I accidentally did a Reply
instead of Replyall and am now resending.


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

* Re: PATCH: completions for su and implicit fg/bg
@ 1999-07-09 13:47 Sven Wischnowsky
  0 siblings, 0 replies; 16+ messages in thread
From: Sven Wischnowsky @ 1999-07-09 13:47 UTC (permalink / raw)
  To: zsh-workers


Peter Stephenson wrote:

> > It's `compset -q' -- and with that I can repeat the question I asked
> > at the time when I sent the completion-quoting-patch: currently the
> > `-q' option only has an effect if the word on the command line is
> > quoted -- should we change it to work on unquoted strings, too?
> 
> Presumably the answer should be yes, for consistency.  I already gave an
> example with backslashing where it should be treated that way.

This allows `compset -q' on unquoted words -- almost. There is a
problem when the match contains characters that have to be quoted. In
such cases the match should be quoted twice (`a b' should be inserted
as `a\\\ b'), but currently the completion code is far from being
prepared for such double-quoting and I'm seeing to much places where
changes are needed for a quick patch.
I'll take care of that later.

Bye
 Sven

diff -u os/Zle/compctl.c Src/Zle/compctl.c
--- os/Zle/compctl.c	Fri Jul  9 10:56:31 1999
+++ Src/Zle/compctl.c	Fri Jul  9 15:41:02 1999
@@ -2096,9 +2096,7 @@
     case 'P': test = CVT_PREPAT; break;
     case 's': test = CVT_SUFNUM; break;
     case 'S': test = CVT_SUFPAT; break;
-    case 'q': return !(compquote && *compquote &&
-		       (*compquote == '\'' || *compquote == '"') &&
-		       !set_comp_sepptr());
+    case 'q': return set_comp_sepptr();
     default:
 	zerrnam(name, "bad option -%c", NULL, argv[0][1]);
 	return 1;
diff -u os/Zle/zle_tricky.c Src/Zle/zle_tricky.c
--- os/Zle/zle_tricky.c	Fri Jul  9 10:56:33 1999
+++ Src/Zle/zle_tricky.c	Fri Jul  9 15:18:10 1999
@@ -5171,10 +5171,16 @@
 	zsfree(compisuffix);
 	compisuffix = ztrdup("");
 	zsfree(compqiprefix);
-	compqiprefix = qp;
 	zsfree(compqisuffix);
-	compqisuffix = qs;
-
+	if (instring) {
+	    compqiprefix = qp;
+	    compqisuffix = qs;
+	} else {
+	    compqiprefix = ztrdup(quotename(qp, NULL));
+	    zsfree(qp);
+	    compqisuffix = ztrdup(quotename(qs, NULL));
+	    zsfree(qs);
+	}
 	freearray(compwords);
 	i = countlinknodes(foo);
 	compwords = (char **) zalloc((i + 1) * sizeof(char *));
diff -u od/Zsh/compwid.yo Doc/Zsh/compwid.yo
--- od/Zsh/compwid.yo	Fri Jul  9 10:56:41 1999
+++ Doc/Zsh/compwid.yo	Fri Jul  9 15:42:36 1999
@@ -620,7 +620,7 @@
 testing and modification is performed as if it were not given.
 )
 item(tt(-q))(
-If the cursor is currently inside single or double quotes, the word
+The word
 currently being completed is split in separate words at the spaces. The 
 resulting words are stored in the tt(words) array, and tt(PREFIX),
 tt(SUFFIX), tt(QIPREFIX), and tt(QISUFFIX) are modified to reflect the 

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


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

* Re: PATCH: completions for su and implicit fg/bg
  1999-07-09 10:44 Sven Wischnowsky
@ 1999-07-09 12:34 ` Peter Stephenson
       [not found]   ` <3785FAFB.3E9FDD41@thoth.u-net.com>
  0 siblings, 1 reply; 16+ messages in thread
From: Peter Stephenson @ 1999-07-09 12:34 UTC (permalink / raw)
  To: zsh-workers

Sven Wischnowsky wrote:
> Peter Stephenson wrote:
> > I think the code in _first was deliberately left commented because it gets
> > run every time, but the impact of this change is minimal.
> 
> Right. And since we only want it in command position, we should
> probably put it in _command_names.

Yes, of course that's the right place.  This patch moves it there.
Also, the obvious way of getting the shell is from $SHELL, so I added that
to _su.

> It's `compset -q' -- and with that I can repeat the question I asked
> at the time when I sent the completion-quoting-patch: currently the
> `-q' option only has an effect if the word on the command line is
> quoted -- should we change it to work on unquoted strings, too?

Presumably the answer should be yes, for consistency.  I already gave an
example with backslashing where it should be treated that way.

> And: nothing against giving _normal (an) optional argument(s) that
> will be put at the front of $words. (_normal is one of the older
> functions that survived (with changes) the transition from reporting
> command line words as positional parameters to the $words array we
> have now; that's why nobody made it accept arguments again, I think).

Sounds reasonable, but I haven't looked at this.

--- Completion/Base/_command_names.cn	Tue Apr 13 09:37:36 1999
+++ Completion/Base/_command_names	Fri Jul  9 14:27:33 1999
@@ -2,6 +2,13 @@
 
 local nm=$compstate[nmatches] ret=1
 
+
+# Complete jobs in implicit fg and bg
+if [[ "$PREFIX[1]" = "%" ]]; then
+  compgen -j -P '%'
+  [[ nm -ne compstate[nmatches] ]] && return
+fi
+
 compgen -c && ret=0
 
 if [[ nm -eq compstate[nmatches] ]]; then
--- Completion/Base/_first.cn	Fri Jul  9 12:04:39 1999
+++ Completion/Base/_first	Fri Jul  9 14:26:33 1999
@@ -61,8 +61,3 @@
 #         (( i++ ))
 #       done
 #     fi
-
-# Complete jobs in implicit fg and bg
-if [[ "$CURRENT" = 1 && "$PREFIX[1]" = "%" ]]; then
-  compgen -j -P '%'
-fi
--- Completion/User/_su.cn	Fri Jul  9 14:28:48 1999
+++ Completion/User/_su	Fri Jul  9 14:30:28 1999
@@ -14,7 +14,7 @@
   return
 fi
 
-shell=${"$(egrep "^$usr:" </etc/passwd)"##*:}
+shell=${SHELL:-"$(egrep "^$usr:" </etc/passwd)"##*:}
 compset -n $base
 for name in $shell $shell:t -default-; do
   comp="$_comps[$name]"

-- 
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] 16+ messages in thread

* Re: PATCH: completions for su and implicit fg/bg
@ 1999-07-09 10:44 Sven Wischnowsky
  1999-07-09 12:34 ` Peter Stephenson
  0 siblings, 1 reply; 16+ messages in thread
From: Sven Wischnowsky @ 1999-07-09 10:44 UTC (permalink / raw)
  To: zsh-workers


Peter Stephenson wrote:

> Oliver Kiddle wrote:
> > First, is a patch to _first which completes jobs after an initial % on
> > the command line.
> 
> I think the code in _first was deliberately left commented because it gets
> run every time, but the impact of this change is minimal.

Right. And since we only want it in command position, we should
probably put it in _command_names.

> > This is useful when foregrounding or backgrounding a
> > process without fg/bg. This feature seems to be undocumented actually.
> 
> Hmm, I thought it was an option, but it seems it's run unconditionally at
> the top of execcmd().  What is an option is AUTO_RESUME.

It's in builtins.yo under `bg' and `fg'.

> > I've included a basic completion for the
> > common shells which just does the -c option.
> 
> It really needs to be told to treat a (possibly quoted) word after -c as a
> complete command line.  I've forgotten how to do that.

It's `compset -q' -- and with that I can repeat the question I asked
at the time when I sent the completion-quoting-patch: currently the
`-q' option only has an effect if the word on the command line is
quoted -- should we change it to work on unquoted strings, too?

And: nothing against giving _normal (an) optional argument(s) that
will be put at the front of $words. (_normal is one of the older
functions that survived (with changes) the transition from reporting
command line words as positional parameters to the $words array we
have now; that's why nobody made it accept arguments again, I think).

Bye
 Sven


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


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

end of thread, other threads:[~1999-07-19 14:09 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-07-09 10:23 PATCH: completions for su and implicit fg/bg Oliver Kiddle
1999-07-09 10:04 ` Peter Stephenson
1999-07-09 10:40 ` Andrej Borsenkow
1999-07-09 10:44 Sven Wischnowsky
1999-07-09 12:34 ` Peter Stephenson
     [not found]   ` <3785FAFB.3E9FDD41@thoth.u-net.com>
1999-07-09 13:53     ` Oliver Kiddle
1999-07-09 14:47       ` Peter Stephenson
1999-07-09 15:53         ` Oliver Kiddle
1999-07-09 13:47 Sven Wischnowsky
1999-07-12 10:39 Sven Wischnowsky
1999-07-12 11:27 ` Peter Stephenson
1999-07-12 12:11 Sven Wischnowsky
1999-07-12 14:29 ` Peter Stephenson
1999-07-13  9:02 Sven Wischnowsky
1999-07-19 13:58 Sven Wischnowsky
1999-07-19 13:38 ` 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).