zsh-users
 help / color / mirror / code / Atom feed
* zsh Newbie wants to complete mutt email addresses or aliases
@ 2002-04-30 19:22 Kingsley G. Morse Jr.
  2002-04-30 19:34 ` Clint Adams
  0 siblings, 1 reply; 10+ messages in thread
From: Kingsley G. Morse Jr. @ 2002-04-30 19:22 UTC (permalink / raw)
  To: zsh-users

Hi everyone!

I'm new here. Linux Magazine's recent article on migrating from bash
persuaded me to try zsh. I'm glad to see it has a friendly license and
naturally I'm looking forward to fully utilizing zsh's completions.

The main reason that I'm writing is to ask for advice on configuring zsh
to complete mutt's destination email addresses.

For example, can zsh be configured to complete the following

        $ mutt -s "A Silly Subject" Joe_Do<tab>

so that "Joe_Do" is expanded to the correct email address
Joe_Doe@somewhere.com"?

I'd also be OK with expanding "Joe_Do" to the correct mutt address alias
"Joe_Doe".

Thanks,
Kingsley


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

* Re: zsh Newbie wants to complete mutt email addresses or aliases
  2002-04-30 19:22 zsh Newbie wants to complete mutt email addresses or aliases Kingsley G. Morse Jr.
@ 2002-04-30 19:34 ` Clint Adams
  2002-04-30 20:03   ` Phil Pennock
  2002-04-30 20:17   ` Bart Schaefer
  0 siblings, 2 replies; 10+ messages in thread
From: Clint Adams @ 2002-04-30 19:34 UTC (permalink / raw)
  To: Kingsley G. Morse Jr.; +Cc: zsh-users

> The main reason that I'm writing is to ask for advice on configuring zsh
> to complete mutt's destination email addresses.
> 
> For example, can zsh be configured to complete the following
> 
>         $ mutt -s "A Silly Subject" Joe_Do<tab>

Currently, mutt completion doesn't know about aliases, though this
should be trivial to change.

Right now it tries to complete destination addresses based on users and
hosts it knows about, which probably isn't too convenient for what you
want to achieve.

Do you keep your aliases in .muttrc or elsewhere?


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

* Re: zsh Newbie wants to complete mutt email addresses or aliases
  2002-04-30 19:34 ` Clint Adams
@ 2002-04-30 20:03   ` Phil Pennock
  2002-04-30 20:17   ` Bart Schaefer
  1 sibling, 0 replies; 10+ messages in thread
From: Phil Pennock @ 2002-04-30 20:03 UTC (permalink / raw)
  To: zsh-users

On 2002-04-30 at 15:34 -0400, Clint Adams wrote:
> Currently, mutt completion doesn't know about aliases, though this
> should be trivial to change.

Depends.  Have you set up query_command and are you using that?

Perhaps a better route, for someone who cares [1], might be to look at
wrapping zsh completion around the same query command.  Then, if mutt
has been correctly installed at a site, so that the site addressbook is
queries (whether LDAP, NIS or whatever) then zsh would have access to
the same information.

A search for "External Address Queries" in the mutt manual should turn
up the information and specification for the format of the returned
data.


Prettige Koninginnedag,

[1] ie, I'm just throwing this out so that people are aware of it before
    hacking about
-- 
Nihil curo de ista tua stulta superstitione.


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

* Re: zsh Newbie wants to complete mutt email addresses or aliases
  2002-04-30 19:34 ` Clint Adams
  2002-04-30 20:03   ` Phil Pennock
@ 2002-04-30 20:17   ` Bart Schaefer
  2002-04-30 21:31     ` Kingsley G. Morse Jr.
  1 sibling, 1 reply; 10+ messages in thread
From: Bart Schaefer @ 2002-04-30 20:17 UTC (permalink / raw)
  To: zsh-users


zstyle -e ':completion::complete:mutt:*:' users \
	'reply=($(perl -ne '\''print "$1\n"
		  if /^\s+alias\s+(\S+)\s+.*/;'\'' ~/.muttrc 2>/dev/null)
		otheraddress@notinmuttrc.com
		anotheraddress@whoknowswhere.com
		etcetc@andsoforth.net)'

You can probably figure out how to extend this to emit the addresses from
the muttrc alias lines instead of just the alias keywords.


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

* Re: zsh Newbie wants to complete mutt email addresses or aliases
  2002-04-30 20:17   ` Bart Schaefer
@ 2002-04-30 21:31     ` Kingsley G. Morse Jr.
  2002-04-30 21:48       ` Bart Schaefer
  0 siblings, 1 reply; 10+ messages in thread
From: Kingsley G. Morse Jr. @ 2002-04-30 21:31 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-users

Bart,

Thanks for the code. 

I'm OK with just completing aliases and appreciate your pragmatic
approach.

However, probably due to my inexperience, I was unable to get your code
to work after 

1.) deleting the hard coded email addresses, leaving

        zstyle -e ':completion::complete:mutt:*:' users \
        'reply=($(perl -ne '\''print "$1\n"
                  if /^\s+alias\s+(\S+)\s+.*/;'\'' ~/.muttrc 2>/dev/null))'

2.) putting it in .zshrc and restarting zsh, and failing that,

3.) entering it at zsh's prompt.

When I press <tab> after typing the start of an alias, ie:

        $ mutt -s "A silly subject" Joe_Do<tab>

zsh returns the same error message as before:

        No matches for: `recipient', `login name', `user', or `corrections'

Since I'm so new to zsh, perhaps you can easily suggest what I might try
doing differently.

Thanks,
Kingsley

to work On Tue:13:17, Bart Schaefer wrote:
> 
> zstyle -e ':completion::complete:mutt:*:' users \ 
>   'reply=($(perl -ne '\''print "$1\n"
>          if /^\s+alias\s+(\S+)\s+.*/;'\'' ~/.muttrc 2>/dev/null)
>        otheraddress@notinmuttrc.com 
>        anotheraddress@whoknowswhere.com
>        etcetc@andsoforth.net)'
> 
> You can probably figure out how to extend this to emit the addresses
> from the muttrc alias lines instead of just the alias keywords.

-- 


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

* Re: zsh Newbie wants to complete mutt email addresses or aliases
  2002-04-30 21:31     ` Kingsley G. Morse Jr.
@ 2002-04-30 21:48       ` Bart Schaefer
  2002-04-30 21:54         ` Marius Strom
  0 siblings, 1 reply; 10+ messages in thread
From: Bart Schaefer @ 2002-04-30 21:48 UTC (permalink / raw)
  To: Kingsley G. Morse Jr.; +Cc: zsh-users

On Tue, 30 Apr 2002, Kingsley G. Morse Jr. wrote:

> 1.) deleting the hard coded email addresses, leaving
>
>         zstyle -e ':completion::complete:mutt:*:' users \
>         'reply=($(perl -ne '\''print "$1\n"
>                   if /^\s+alias\s+(\S+)\s+.*/;'\'' ~/.muttrc 2>/dev/null))'
>
> When I press <tab> after typing the start of an alias [...]
> zsh returns the same error message as before [...]

First thing to try is, run the perl all by itself:

perl -ne 'print "$1\n" if /^\s+alias\s+(\S+)\s+.*/;' ~/.muttrc

Does this produce an error message?  Does it produce the right output?

If that appears to work, you dan debug the completion itself by using

$ mutt -s "A silly subject" Joe_Do<C-x ?>

That is, type control-x question-mark instead of tab.  This will dump a
trace of the completion code to a temp file, where you can look at it.
Search it for "perl" to see whether and how the style above is being used.


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

* Re: zsh Newbie wants to complete mutt email addresses or aliases
  2002-04-30 21:48       ` Bart Schaefer
@ 2002-04-30 21:54         ` Marius Strom
  2002-04-30 22:11           ` Bart Schaefer
                             ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Marius Strom @ 2002-04-30 21:54 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Kingsley G. Morse Jr., zsh-users

Take out the initial \s+ in your perl regex, that should clear it up
(alias lines usually don't have preceeding whitespace.)

On Tue, 30 Apr 2002, Bart Schaefer wrote:
> First thing to try is, run the perl all by itself:
> 
> perl -ne 'print "$1\n" if /^\s+alias\s+(\S+)\s+.*/;' ~/.muttrc
> 
> Does this produce an error message?  Does it produce the right output?
> 
> If that appears to work, you dan debug the completion itself by using
> 
> $ mutt -s "A silly subject" Joe_Do<C-x ?>
> 
> That is, type control-x question-mark instead of tab.  This will dump a
> trace of the completion code to a temp file, where you can look at it.
> Search it for "perl" to see whether and how the style above is being used.

-- 
                       /------------------------------------------------->
Marius Strom           | Always carry a short length of fibre-optic cable.
Professional Geek      | If you get lost, then you can drop it on the
System/Network Admin   | ground, wait 10 minutes, and ask the backhoe
http://www.alpha1.net/ | operator how to get back to civilization.
                       \-------------| Alan Frame |---------------------->


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

* Re: zsh Newbie wants to complete mutt email addresses or aliases
  2002-04-30 21:54         ` Marius Strom
@ 2002-04-30 22:11           ` Bart Schaefer
  2002-04-30 23:18           ` Kingsley G. Morse Jr.
  2002-05-01  8:41           ` Bruno Bonfils
  2 siblings, 0 replies; 10+ messages in thread
From: Bart Schaefer @ 2002-04-30 22:11 UTC (permalink / raw)
  To: Marius Strom; +Cc: Kingsley G. Morse Jr., zsh-users

On Tue, 30 Apr 2002, Marius Strom wrote:

> Take out the initial \s+ in your perl regex, that should clear it up

D'oh!  That should have been \s* ...


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

* Re: zsh Newbie wants to complete mutt email addresses or aliases
  2002-04-30 21:54         ` Marius Strom
  2002-04-30 22:11           ` Bart Schaefer
@ 2002-04-30 23:18           ` Kingsley G. Morse Jr.
  2002-05-01  8:41           ` Bruno Bonfils
  2 siblings, 0 replies; 10+ messages in thread
From: Kingsley G. Morse Jr. @ 2002-04-30 23:18 UTC (permalink / raw)
  To: Marius Strom; +Cc: zsh-users

On Tue:16:54, Marius Strom wrote:
> Take out the initial \s+
[...]

Thanks! 

It worked!

Two minor observations:

1.) Although the zstyle/perl code worked as we expected when I entered it
at zsh's prompt, when I added it to .zshrc and subsequently started zsh,
it reported 

        "no such file or directory"

until I appended the first two (out of three) lines of the code. The
resulting .zshrc code that works for me is

        zstyle -e ':completion::complete:mutt:*:' users 'reply=($(perl -ne '\''print "$1\n"
                  if /^\s*alias\s+(\S+)\s+.*/;'\'' ~/.muttrc 2> /dev/null ))'

2.) Now when I use <tab> to complete mutt's email aliases, the completed
aliases sometimes end with an "@", which conveniently goes away when I
press <enter> to run mutt.


All in all... all's well that ends well.

Marius: I like your lost cable signature.

All: As a small token of my appreciation for your time and attention,
here's a tame joke:

        Q: How much does it cost to pierce a pirate's ears?

        A: A buccaneer!

Thanks,
Kingsley


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

* Re: zsh Newbie wants to complete mutt email addresses or aliases
  2002-04-30 21:54         ` Marius Strom
  2002-04-30 22:11           ` Bart Schaefer
  2002-04-30 23:18           ` Kingsley G. Morse Jr.
@ 2002-05-01  8:41           ` Bruno Bonfils
  2 siblings, 0 replies; 10+ messages in thread
From: Bruno Bonfils @ 2002-05-01  8:41 UTC (permalink / raw)
  To: zsh-users

I wrote this :

    # added by asyd (20020304)
    if [ -r ~/.muttrc ]; then

       # use cache
       if ( [[ ${+_list_alias} -eq 0 ]] || _cache_invalid mutt_alias ) &&
          ! _retrieve_cache mutt_alias; then

          _list_alias=(${(o)${${(M)${(f)"$(< ~/.muttrc)"}##alias*}/alias /}%% *})

          _store_cache mutt_alias _list_alias
       fi

       _wanted alias expl 'alias name' compadd -q -S, $_list_alias
    fi


-- 
Bruno Bonfils
Admin Sys GNU/Linux

 http://www.debian-fr.org/


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

end of thread, other threads:[~2002-05-01  8:41 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-30 19:22 zsh Newbie wants to complete mutt email addresses or aliases Kingsley G. Morse Jr.
2002-04-30 19:34 ` Clint Adams
2002-04-30 20:03   ` Phil Pennock
2002-04-30 20:17   ` Bart Schaefer
2002-04-30 21:31     ` Kingsley G. Morse Jr.
2002-04-30 21:48       ` Bart Schaefer
2002-04-30 21:54         ` Marius Strom
2002-04-30 22:11           ` Bart Schaefer
2002-04-30 23:18           ` Kingsley G. Morse Jr.
2002-05-01  8:41           ` Bruno Bonfils

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