zsh-workers
 help / color / mirror / code / Atom feed
* Re: PATCH: completion with redirections
@ 1999-01-25 13:43 Sven Wischnowsky
  1999-01-25 14:01 ` Peter Stephenson
  0 siblings, 1 reply; 9+ messages in thread
From: Sven Wischnowsky @ 1999-01-25 13:43 UTC (permalink / raw)
  To: zsh-workers


I wrote:

> 
> Oliver Kiddle wrote:
> 
> > I would want the command-line 'giftopnm < ' to only complete with .gif files.
> > Is it already possible to do this?
> 
> Currently not. I'll have a look at this for the new style completion
> stuff, with compctl there is no way to specify `redirection for
> command ...' anyway.

Well, the new style stuff had this information in the argv-array
alread (with argv[1] being the command). The patch below also makes
the operator itself available in COMMAND. This may be surprising, but
COMMAND is used as a kind of direct context anyway (in subscript
COMMAND contains the parameter name, for example).
The code uses the tokstrings-array from lex.c for the operator
strings. There is a problem: this array contains ")" instead of '>',
so one will currently get a wrong string for such redirections. Is
this a typo or is there some hidden reason for it (i.e. can I change
the table or do I have to build a different table in zle_tricky.c)?

Bye
 Sven

*** os/lex.c	Mon Jan 25 12:07:41 1999
--- Src/lex.c	Mon Jan 25 14:35:41 1999
***************
*** 109,115 ****
   
  /* text of puctuation tokens */
  
! static char *tokstrings[WHILE + 1] = {
      NULL,	/* NULLTOK	  0  */
      ";",	/* SEPER	     */
      "\\n",	/* NEWLIN	     */
--- 109,116 ----
   
  /* text of puctuation tokens */
  
! /**/
! char *tokstrings[WHILE + 1] = {
      NULL,	/* NULLTOK	  0  */
      ";",	/* SEPER	     */
      "\\n",	/* NEWLIN	     */
*** os/Zle/zle_tricky.c	Mon Jan 25 11:22:36 1999
--- Src/Zle/zle_tricky.c	Mon Jan 25 14:34:04 1999
***************
*** 447,452 ****
--- 447,456 ----
  
  static int lincmd, linredir;
  
+ /* The string for the redirection operator. */
+ 
+ static char *rdstr;
+ 
  /* Non-zero if the last completion done was ambiguous (used to find   *
   * out if AUTOMENU should start).  More precisely, it's nonzero after *
   * successfully doing any completion, unless the completion was       *
***************
*** 998,1003 ****
--- 1002,1009 ----
  	    oins = ins;
  	    /* Get the next token. */
  	    ctxtlex();
+ 	    if (inredir)
+ 		rdstr = tokstrings[tok];
  	    if (tok == DINPAR)
  		tokstr = NULL;
  
***************
*** 3229,3237 ****
  		    usea = 0;
  		} else if (lincmd)
  		    compcontext = (insubscr ? "subscript" : "command");
! 		else if (linredir)
  		    compcontext = "redirect";
! 		else
  		    switch (inwhat) {
  		    case IN_ENV:
  			compcontext = "value";
--- 3235,3245 ----
  		    usea = 0;
  		} else if (lincmd)
  		    compcontext = (insubscr ? "subscript" : "command");
! 		else if (linredir) {
  		    compcontext = "redirect";
! 		    if (rdstr)
! 			compcommand = rdstr;
! 		} else
  		    switch (inwhat) {
  		    case IN_ENV:
  			compcontext = "value";

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


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

* Re: PATCH: completion with redirections
  1999-01-25 13:43 PATCH: completion with redirections Sven Wischnowsky
@ 1999-01-25 14:01 ` Peter Stephenson
  1999-01-26 17:56   ` Bart Schaefer
  0 siblings, 1 reply; 9+ messages in thread
From: Peter Stephenson @ 1999-01-25 14:01 UTC (permalink / raw)
  To: zsh-workers

Sven Wischnowsky wrote:
> There is a problem: this array contains ")" instead of '>',
> so one will currently get a wrong string for such redirections. Is
> this a typo or is there some hidden reason for it (i.e. can I change
> the table or do I have to build a different table in zle_tricky.c)?

I can't see how it can possibly be right as it stands, looking at
what's around it.

*** Src/lex.c.outang	Mon Jan 25 14:30:37 1999
--- Src/lex.c	Mon Jan 25 14:59:49 1999
***************
*** 121,127 ****
      ")",	/* OUTPAR	     */
      "||",	/* DBAR		     */
      "&&",	/* DAMPER	     */
!     ")",	/* OUTANG	  10 */
      ">|",	/* OUTANGBANG	     */
      ">>",	/* DOUTANG	     */
      ">>|",	/* DOUTANGBANG	     */
--- 121,127 ----
      ")",	/* OUTPAR	     */
      "||",	/* DBAR		     */
      "&&",	/* DAMPER	     */
!     ">",	/* OUTANG	  10 */
      ">|",	/* OUTANGBANG	     */
      ">>",	/* DOUTANG	     */
      ">>|",	/* DOUTANGBANG	     */

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

* Re: PATCH: completion with redirections
  1999-01-25 14:01 ` Peter Stephenson
@ 1999-01-26 17:56   ` Bart Schaefer
  1999-01-26 18:05     ` Phil Pennock
  0 siblings, 1 reply; 9+ messages in thread
From: Bart Schaefer @ 1999-01-26 17:56 UTC (permalink / raw)
  To: Peter Stephenson, zsh-workers

On Jan 25,  3:01pm, Peter Stephenson wrote:
} Subject: Re: PATCH: completion with redirections
}
} Sven Wischnowsky wrote:
} > There is a problem: this array contains ")" instead of '>',
} 
} I can't see how it can possibly be right as it stands, looking at
} what's around it.

This typo, if that's what it is, has been around for a long time; it'
that way in globals.h in 3.0.5.  Where has tokstrings (not) been used
all this time, that no one ever noticed?

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


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

* Re: PATCH: completion with redirections
  1999-01-26 17:56   ` Bart Schaefer
@ 1999-01-26 18:05     ` Phil Pennock
  0 siblings, 0 replies; 9+ messages in thread
From: Phil Pennock @ 1999-01-26 18:05 UTC (permalink / raw)
  To: zsh-workers

Typing away merrily, Bart Schaefer produced the immortal words:
> } > There is a problem: this array contains ")" instead of '>',
> } 
> } I can't see how it can possibly be right as it stands, looking at
> } what's around it.
> 
> This typo, if that's what it is, has been around for a long time; it'
> that way in globals.h in 3.0.5.  Where has tokstrings (not) been used
> all this time, that no one ever noticed?

I tried analysing this sometime in December.  I saw what now appears to
be a typo, tried to figure it out, and got lost trying to figure out
where it was being called from.  There's one place which used the array
in a specific condition (don't have zsh sources available now, sorry),
and I couldn't manage to trigger the condition.

'fgrep' and 'tags' are your friends.  ;^)

Thinking about this, I should have mentioned it then.  Sorry.
-- 
--> Phil Pennock ; GAT d- s+:+ a23 C++(++++) UL++++/I+++/S+++/B++/H+$ P++@$
L+++ E-@ W(+) N>++ o !K w--- O>+ M V !PS PE Y+ PGP+ t-- 5++ X+ R !tv b++>+++
DI+ D+ G+ e+ h* r y?


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

* Re: PATCH: completion with redirections
@ 1999-01-27  8:13 Sven Wischnowsky
  0 siblings, 0 replies; 9+ messages in thread
From: Sven Wischnowsky @ 1999-01-27  8:13 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> 
> On Jan 25,  3:01pm, Peter Stephenson wrote:
> } Subject: Re: PATCH: completion with redirections
> }
> } Sven Wischnowsky wrote:
> } > There is a problem: this array contains ")" instead of '>',
> } 
> } I can't see how it can possibly be right as it stands, looking at
> } what's around it.
> 
> This typo, if that's what it is, has been around for a long time; it'
> that way in globals.h in 3.0.5.  Where has tokstrings (not) been used
> all this time, that no one ever noticed?

That's why I was reluctant to change it without asking first.

The only place where tokstrings was used is in exalias() if that is
called with tokstring=NULL after spell-checking, which happens
whenever a redirection operator is parsed. The value from the table
will be used if someone calls yylex(), gets the token for a
redirection operator and uses tokstr before calling yylex()
again. After searching a bit I still can't find a place where this
happens.


Bye
 Sven


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


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

* Re: PATCH: completion with redirections
@ 1999-01-25  9:00 Sven Wischnowsky
  0 siblings, 0 replies; 9+ messages in thread
From: Sven Wischnowsky @ 1999-01-25  9:00 UTC (permalink / raw)
  To: zsh-workers


Oliver Kiddle wrote:

> I would want the command-line 'giftopnm < ' to only complete with .gif files.
> Is it already possible to do this?

Currently not. I'll have a look at this for the new style completion
stuff, with compctl there is no way to specify `redirection for
command ...' anyway.

Bye
 Sven


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


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

* Re: PATCH: completion with redirections
  1999-01-22 17:11 ` Oliver Kiddle
@ 1999-01-23  6:26   ` Bart Schaefer
  0 siblings, 0 replies; 9+ messages in thread
From: Bart Schaefer @ 1999-01-23  6:26 UTC (permalink / raw)
  To: zsh-workers

On Jan 22,  6:11pm, Oliver Kiddle wrote:
} Subject: Re: PATCH: completion with redirections
}
} I would want the command-line 'giftopnm < ' to only complete with .gif files.
} Is it already possible to do this?

Unfortunately I think completion considers a redirction operator and the
one word immediately following it to be independent of the current command.
For example, they don't show up in the array assigned by "read -Ac" in a
compctl -K function.  So at the moment you get file completion after any
redirection, and that's it.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


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

* Re: PATCH: completion with redirections
  1999-01-22 16:11 Sven Wischnowsky
@ 1999-01-22 17:11 ` Oliver Kiddle
  1999-01-23  6:26   ` Bart Schaefer
  0 siblings, 1 reply; 9+ messages in thread
From: Oliver Kiddle @ 1999-01-22 17:11 UTC (permalink / raw)
  To: Sven Wischnowsky, zsh-workers

At 17:11 22/01/99 +0100, Sven Wischnowsky wrote:

>Completion always had the problem that it counted redirections
>appearing in the command line as arguments if you were not completing
>the string (filename) after the redirection operator itself.

I'm not quite sure what you mean here but it reminded me of one feature for
the completion which might exist but would be a useful addition if it
doesn't: the ability to apply completion rules to files directed into
commands. For example, 
I would want the command-line 'giftopnm < ' to only complete with .gif files.
Is it already possible to do this?

Oliver Kiddle


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

* PATCH: completion with redirections
@ 1999-01-22 16:11 Sven Wischnowsky
  1999-01-22 17:11 ` Oliver Kiddle
  0 siblings, 1 reply; 9+ messages in thread
From: Sven Wischnowsky @ 1999-01-22 16:11 UTC (permalink / raw)
  To: zsh-workers


Completion always had the problem that it counted redirections
appearing in the command line as arguments if you were not completing
the string (filename) after the redirection operator itself.

The patch below tries to avoid this. It seems to work under several
circumstances. (But it looks suspiciously simple, doesn't it?)

Bye
 Sven

*** os/Zle/zle_tricky.c	Fri Jan 22 17:06:30 1999
--- Src/Zle/zle_tricky.c	Fri Jan 22 17:06:37 1999
***************
*** 1011,1017 ****
  		rd = linredir;
  		if (inwhat == IN_NOTHING && incond)
  		    inwhat = IN_COND;
! 	    }
  	    if (!tokstr)
  		continue;
  	    /* Hack to allow completion after `repeat n do'. */
--- 1011,1018 ----
  		rd = linredir;
  		if (inwhat == IN_NOTHING && incond)
  		    inwhat = IN_COND;
! 	    } else if (linredir)
! 		continue;
  	    if (!tokstr)
  		continue;
  	    /* Hack to allow completion after `repeat n do'. */

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


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

end of thread, other threads:[~1999-01-27  8:13 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-01-25 13:43 PATCH: completion with redirections Sven Wischnowsky
1999-01-25 14:01 ` Peter Stephenson
1999-01-26 17:56   ` Bart Schaefer
1999-01-26 18:05     ` Phil Pennock
  -- strict thread matches above, loose matches on Subject: below --
1999-01-27  8:13 Sven Wischnowsky
1999-01-25  9:00 Sven Wischnowsky
1999-01-22 16:11 Sven Wischnowsky
1999-01-22 17:11 ` Oliver Kiddle
1999-01-23  6:26   ` Bart Schaefer

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