zsh-users
 help / color / mirror / code / Atom feed
* Alias and zstyle contexts
@ 2014-12-08 23:02 Silas Silva
  2014-12-08 23:24 ` Mikael Magnusson
  2014-12-08 23:25 ` Frank Terbeck
  0 siblings, 2 replies; 6+ messages in thread
From: Silas Silva @ 2014-12-08 23:02 UTC (permalink / raw)
  To: zsh-users

Hi there!

Fortunatelly, aliases use the same context of original commands, which
which make things much easier.  But a little problem just came up:

mutt's -f option looks for mailboxes using the mail-directory style.  I
have a "muttw" alias that I'd like to load mailboxes from another
directory, but the context is the same.

I could solve this having a function called muttw, copying original
_mutt completion to _muttw and changing just one line, but this looks
ugly.  Is there an simpler way?

Thank you very much!

-- 
Silas Silva


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

* Re: Alias and zstyle contexts
  2014-12-08 23:02 Alias and zstyle contexts Silas Silva
@ 2014-12-08 23:24 ` Mikael Magnusson
  2014-12-09 16:11   ` Silas Silva
  2014-12-08 23:25 ` Frank Terbeck
  1 sibling, 1 reply; 6+ messages in thread
From: Mikael Magnusson @ 2014-12-08 23:24 UTC (permalink / raw)
  To: Zsh Users

On Tue, Dec 9, 2014 at 12:02 AM, Silas Silva <silasdb@gmail.com> wrote:
> Hi there!
>
> Fortunatelly, aliases use the same context of original commands, which
> which make things much easier.  But a little problem just came up:
>
> mutt's -f option looks for mailboxes using the mail-directory style.  I
> have a "muttw" alias that I'd like to load mailboxes from another
> directory, but the context is the same.
>
> I could solve this having a function called muttw, copying original
> _mutt completion to _muttw and changing just one line, but this looks
> ugly.  Is there an simpler way?
>
> Thank you very much!

Just making a function and saying compdef muttw=mutt should be enough.

-- 
Mikael Magnusson


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

* Re: Alias and zstyle contexts
  2014-12-08 23:02 Alias and zstyle contexts Silas Silva
  2014-12-08 23:24 ` Mikael Magnusson
@ 2014-12-08 23:25 ` Frank Terbeck
  1 sibling, 0 replies; 6+ messages in thread
From: Frank Terbeck @ 2014-12-08 23:25 UTC (permalink / raw)
  To: zsh-users

Silas Silva wrote:
[...]
> mutt's -f option looks for mailboxes using the mail-directory style.  I
> have a "muttw" alias that I'd like to load mailboxes from another
> directory, but the context is the same.
>
> I could solve this having a function called muttw, copying original
> _mutt completion to _muttw and changing just one line, but this looks
> ugly.  Is there an simpler way?

% compdef muttw=mutt

should do the trick.


Regards, Frank


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

* Re: Alias and zstyle contexts
  2014-12-08 23:24 ` Mikael Magnusson
@ 2014-12-09 16:11   ` Silas Silva
  2014-12-10  1:41     ` Mikael Magnusson
  0 siblings, 1 reply; 6+ messages in thread
From: Silas Silva @ 2014-12-09 16:11 UTC (permalink / raw)
  To: Mikael Magnusson; +Cc: Zsh Users

On Tue, Dec 09, 2014 at 12:24:34AM +0100, Mikael Magnusson wrote:
(...)
> > mutt's -f option looks for mailboxes using the mail-directory style.  I
> > have a "muttw" alias that I'd like to load mailboxes from another
> > directory, but the context is the same.
(...)
> 
> Just making a function and saying compdef muttw=mutt should be enough.

Hi!

It works fine, thank you!  But, unfortunately zsh's _mutt file checks
if $curcontext is mutt or some other alternatives.  Since I now have
muttw context, it doesn't work well.  Is it possible to trick _mutt
without having to change its code?

Thank you very much.

-- 
Silas Silva


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

* Re: Alias and zstyle contexts
  2014-12-09 16:11   ` Silas Silva
@ 2014-12-10  1:41     ` Mikael Magnusson
  2014-12-11 17:22       ` Silas Silva
  0 siblings, 1 reply; 6+ messages in thread
From: Mikael Magnusson @ 2014-12-10  1:41 UTC (permalink / raw)
  To: Mikael Magnusson, Zsh Users

On Tue, Dec 9, 2014 at 5:11 PM, Silas Silva <silasdb@gmail.com> wrote:
> On Tue, Dec 09, 2014 at 12:24:34AM +0100, Mikael Magnusson wrote:
> (...)
>> > mutt's -f option looks for mailboxes using the mail-directory style.  I
>> > have a "muttw" alias that I'd like to load mailboxes from another
>> > directory, but the context is the same.
> (...)
>>
>> Just making a function and saying compdef muttw=mutt should be enough.
>
> Hi!
>
> It works fine, thank you!  But, unfortunately zsh's _mutt file checks
> if $curcontext is mutt or some other alternatives.  Since I now have
> muttw context, it doesn't work well.  Is it possible to trick _mutt
> without having to change its code?
>
> Thank you very much.

I don't have mutt so I can't try this, and if it doesn't work, maybe
someone else has a suggestion.
compdef -e 'curcontext=:complete:mutt:w:; _mutt' muttw
and then set the mail-directory style for that tag instead. Maybe?
There may be some much more elegant way to do this (if it at all
works).

-- 
Mikael Magnusson


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

* Re: Alias and zstyle contexts
  2014-12-10  1:41     ` Mikael Magnusson
@ 2014-12-11 17:22       ` Silas Silva
  0 siblings, 0 replies; 6+ messages in thread
From: Silas Silva @ 2014-12-11 17:22 UTC (permalink / raw)
  To: zsh-users

On Wed, Dec 10, 2014 at 02:41:29AM +0100, Mikael Magnusson wrote:
> I don't have mutt so I can't try this, and if it doesn't work, maybe
> someone else has a suggestion.
> compdef -e 'curcontext=:complete:mutt:w:; _mutt' muttw
> and then set the mail-directory style for that tag instead. Maybe?
> There may be some much more elegant way to do this (if it at all
> works).

Hi Mikael and guys,

Thank for the tip.  It would work fine, if there wasn't a problem:
_mailboxes has a _mailbox_cache variable that would prevent the code to
evaluate again even in another context.  The workaround I came up with
is:

    compdef -e 'curcontext=:complete:mutt:w:; _mutt; unset _mailbox_cache' muttw

This is not beautiful but it works.

Is a patch to make _mailboxes work with different contexts and yet be
efficient (working with different cache for different context)
desirable?

Thank you very much!

-- 
Silas Silva


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

end of thread, other threads:[~2014-12-11 17:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-08 23:02 Alias and zstyle contexts Silas Silva
2014-12-08 23:24 ` Mikael Magnusson
2014-12-09 16:11   ` Silas Silva
2014-12-10  1:41     ` Mikael Magnusson
2014-12-11 17:22       ` Silas Silva
2014-12-08 23:25 ` Frank Terbeck

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