Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: completion with redirections



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



Messages sorted by: Reverse Date, Date, Thread, Author