zsh-users
 help / color / mirror / code / Atom feed
From: Borsenkow Andrej <Andrej.Borsenkow@mow.siemens.ru>
To: GoTaR <gotar@poczta.onet.pl>
Cc: zsh-users@sunsite.dk
Subject: Re: completions issues
Date: 12 Jul 2002 22:44:56 +0400	[thread overview]
Message-ID: <1026499603.2775.6.camel@localhost.localdomain> (raw)
In-Reply-To: <20020710204701.GA3362@os>

В Чтв, 11.07.2002, в 00:47, GoTaR написал:
> Hi!
> 
> I've got some problems with creating my own rule for sms sending
> program. Here comes the significant part:
> 
> _sms_aliases () {
> 	compadd "$@" $(print ${(f)"$(smsaddr -l | cut -f1)"})
> }
> [...]
> 		_arguments -C \
>                         '-r[remove existing entry]:SMS alias:_sms_aliases'
> 
> smsaddr returns two columns, completion should be done from both, but
> treated as one entry, e. g.:
> 
> $ smsaddr -l
> alias1		608612341
> alias2		504147432
> blias3		603648734
> 
> $ smsaddr -r a[tab]... lias2
> alias1          608612341
> alias2          504147432
> 
> $ smsaddr -r 6[tab]... 08612341
> alias1          608612341
> blias3          603648734
> 
> so one column will be used as comment.
> 
> I will be very grateful for help.
> 

_sms_aliases should check both fields and add the first if any matches.
To prevent completion using own matching use -U flag to compadd.
Something like

ret=1
smsaddr -l  | while read alias number; do
  if [[ $alias == $PREFIX*$SUFFIX || $number == $PREFIX*$SUFFIX ]]; then
     compadd -U -- $alias
     ret=0
   fi
done

return $ret

with obvious error checking. If you want to add numbers as descriptions,
somebody else better explains how to do it :-) 

-andrej


  reply	other threads:[~2002-07-13  7:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-10 20:47 GoTaR
2002-07-12 18:44 ` Borsenkow Andrej [this message]
2002-07-13 19:37   ` GoTaR
2002-07-13 21:20     ` Bart Schaefer
2002-07-14 10:55       ` GoTaR
2002-07-14 21:09         ` Bart Schaefer
2002-07-14  8:57     ` Borsenkow Andrej
2002-07-14 10:49       ` GoTaR

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=1026499603.2775.6.camel@localhost.localdomain \
    --to=andrej.borsenkow@mow.siemens.ru \
    --cc=gotar@poczta.onet.pl \
    --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).