zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: Re: PATCH: completion with redirections
Date: Mon, 25 Jan 1999 14:43:14 +0100 (MET)	[thread overview]
Message-ID: <199901251343.OAA17087@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Sven Wischnowsky's message of Mon, 25 Jan 1999 10:00:25 +0100 (MET)


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


             reply	other threads:[~1999-01-25 13:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-01-25 13:43 Sven Wischnowsky [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199901251343.OAA17087@beta.informatik.hu-berlin.de \
    --to=wischnow@informatik.hu-berlin.de \
    --cc=zsh-workers@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).