zsh-workers
 help / color / mirror / code / Atom feed
* 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 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  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
* 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-27  8:13 PATCH: completion with redirections Sven Wischnowsky
  -- strict thread matches above, loose matches on Subject: below --
1999-01-25 13:43 Sven Wischnowsky
1999-01-25 14:01 ` Peter Stephenson
1999-01-26 17:56   ` Bart Schaefer
1999-01-26 18:05     ` Phil Pennock
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).