zsh-users
 help / color / mirror / code / Atom feed
* completion function with compadd
@ 2005-01-20 18:20 Eric Smith
  2005-01-22 22:22 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Smith @ 2005-01-20 18:20 UTC (permalink / raw)
  To: zsh-users

Hi zsh-list

I use #compdef and compadd in a site_function to do completion
based on words in a file.  But actually the completion is on
the #lines# in the file you give as an argument to compadd.

Is it possible to complete on words within that file.
The example I am looking for is my mutt aliases
file where I want to go:

mutt a<tab>

and get 
mutt alice@inwonderland.com

and not
mutt alias aw "Alice in Wonderland" <alice@inwonderland.com>

thanks guys

-- 
Eric Smith


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: completion function with compadd
  2005-01-20 18:20 completion function with compadd Eric Smith
@ 2005-01-22 22:22 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2005-01-22 22:22 UTC (permalink / raw)
  To: zsh-users

On Jan 20,  7:20pm, Eric Smith wrote:
}
} Is it possible to complete on words within that file.
} The example I am looking for is my mutt aliases

Is there something not working for you if you use the mutt completer
that's included in the zsh distribution?

Theoretically, it handles mutt alias files just fine.  If for some
reason it doesn't, you can create your own plugin function called
"_email-mutt" to do the work.  (Unfortunately the interface to the
plugin is rather poorly documented, but there are examples in the
Completion/Unix/Type/_email_addresses file.)

Just be sure you define the plugin function before you load the
_email_addresses file.  (Autoloading both should work fine.)

} mutt alice@inwonderland.com
} 
} and not
} mutt alias aw "Alice in Wonderland" <alice@inwonderland.com>

For that specific example, assuming that you've somehow assigned the
line from the file to the variable $line, you'd want something like

	compadd ${line/(#b)*<(*)>/$match[1]}

(which assumes extendedglob is set, but it always is in completion).


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-01-22 22:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-20 18:20 completion function with compadd Eric Smith
2005-01-22 22:22 ` Bart Schaefer

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).