zsh-users
 help / color / mirror / code / Atom feed
From: Andy Spiegl <zsh.Andy@spiegl.de>
To: zsh-users@sunsite.dk
Subject: Re: completion with descriptions
Date: Mon, 27 Mar 2006 18:30:58 +0200	[thread overview]
Message-ID: <20060327163058.GA20833@spiegl.de> (raw)
In-Reply-To: <EXCHANGE03k6gYKeiMH000034a5@exchange03.csr.com>

Thank you for the example, Peter!
I tried to dig in deeply into writing completion functions now. :-)

I took _aptitude as a template and came up with the following (see below)
which works as wanted except for the fact that zsh inserts the _whole_ line
(command + description) instead of just the command. *sigh*

Like so:
 condor:~>gigaset del\ \ \ \ \ \ \ \ \ --\ Aufnahme\ löschen
 gigaset commands
 del         -- Aufnahme löschen                                    
 demux       -- Aufnahme mit projectX demultiplexen                 
 details     -- Details anzeigen                                    
 dir         -- Liste der Aufnahmen                                 
 dump        -- Details anzeigen                                    
 mux         -- Video+Audio(s) wieder zu einer MPG-Datei multiplexen
 title       -- Kurzübersicht (Aufnahme-Titel in nur 1 Zeile)       

Can someone see where my error is, please?

Here are the relevant parts of the function:
 (the whole thing is also here: http://andy.spiegl.de/software/_gigaset)

[...]
_arguments -S \
[...]
   '--commands[Liste aller Kommandos]' \
   '1: :->cmds' \
   '*: :->args'

case $state in
  cmds)
    cmds=( ${${(M)${(f)"$(gigaset --commands 2>/dev/null)"}:#* -- *}/(#b) (*[^ ]) #-- (*)/$match[1]:$match[2]:l})
    _describe -t commands "gigaset commands" cmds && ret=0
  ;;
  args)
[...]
  ;;
esac

Thx,
 Andy.

-- 
 For every problem there is one solution which is simple, neat, and wrong. 
   -- Henry L. Mencken 


  reply	other threads:[~2006-03-27 16:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-27 13:27 Andy Spiegl
2006-03-27 13:46 ` Peter Stephenson
2006-03-27 16:30   ` Andy Spiegl [this message]
2006-03-28 16:35     ` Andy Spiegl

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=20060327163058.GA20833@spiegl.de \
    --to=zsh.andy@spiegl.de \
    --cc=zsh-users@sunsite.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).