zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: Re: 6-pws-2
Date: Tue, 31 Aug 1999 14:38:58 +0200 (MET DST)	[thread overview]
Message-ID: <199908311238.OAA29874@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Tanaka Akira's message of 31 Aug 1999 12:37:52 +0900


Tanaka Akira wrote:

> In article <9908301600.AA12634@ibmth.df.unipi.it>,
>   Peter Stephenson <pws@ibmth.df.unipi.it> writes:
> > - Personally, I prefer one single completion function for a suite of
> >   related commands like cvs or pbm, since the accumulated clutter (and
> >   added time to process completion files the first time) is large.  If it
> >   stays the way it is I will change the default for function installation
> >   to keep the subdirectories.
> 
> The separation is sometimes useful for custumizations because we can
> override each function individually. These functions behaves like `hook'.
> I think it is useful that making hooks more easily without adding new files.

Hm. How about making it a bit like a state machine:

In functions like `_cvs' we make (some of) the actions look like
`state=command'. After return from `_arguments' we first look if
there is a user-supplied function, probably using a convenience
function like:

   call() {
    local ret
     if functions "$1" > /dev/null 2>&1; then
      "$1"
      ret=$?
      [[ $# -gt 1 ]] && eval "${2}=$ret"
      return 0
    fi
    return 1
  }

(Defined in `compinit' or in a file `_call' and probably with a better 
name, of course.)

So we would have:

  #compdef cvs

  local state ret

  _arguments ... '*::cvs command:state=command'

  call _cvs_$state ret && return ret

  case $state in
  ...
  command) ...
  esac

Depending on the complexity of the command we would probably have a
loop which steps through several states, probably calling `_arguments' 
again and so on.

If we want to be lazy we could also easily add a new action syntax
that stores a state name in a global (if not made local in a calling
function) parameter with a fixed name.

Would that be acceptable to everyone? Can anyone think of ways to help 
users write such state-machine functions?

Bye
 Sven


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


             reply	other threads:[~1999-08-31 12:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-08-31 12:38 Sven Wischnowsky [this message]
1999-08-31 16:19 ` 6-pws-2 Tanaka Akira
  -- strict thread matches above, loose matches on Subject: below --
1999-09-01  8:46 6-pws-2 Sven Wischnowsky
1999-08-31  8:22 6-pws-2 Sven Wischnowsky
1999-08-31 11:28 ` 6-pws-2 Andrej Borsenkow
1999-08-31 17:10 ` 6-pws-2 Bart Schaefer
1999-09-01  8:24 ` 6-pws-2 Peter Stephenson
1999-08-31  8:15 6-pws-2 Sven Wischnowsky
1999-08-31 21:05 ` 6-pws-2 Bart Schaefer
1999-08-30 16:00 6-pws-2 Peter Stephenson
1999-08-30 21:03 ` 6-pws-2 Bart Schaefer
1999-09-01  8:09   ` 6-pws-2 Peter Stephenson
1999-08-31  3:37 ` 6-pws-2 Tanaka Akira
1999-08-31  9:27 ` 6-pws-2 Ollivier Robert

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=199908311238.OAA29874@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).