Re: Conditional macro?

2018-12-07 Thread Michael Wagner
On Dec 07, 2018 at 09:57:38, Kevin J. McCarthy wrote:
> On Fri, Dec 07, 2018 at 03:47:05PM +0100, Michael Wagner wrote:
> > I have tested this and when I change the folder the error message is
> > 
> > .: unknown command
> 
> You'll need to use the push command to execute functions inside a folder
> hook:
>  http://www.mutt.org/doc/manual/#push
> 
> However, the push command is a bit tricky in this case.  The pushed functions
> (e.g., ) aren't run immediately: they are stored up and run *after* all
> the folder-hooks are done.
> 
> They are stored up in a "stack", like a stack of plates.  Each new push adds a
> "plate" (i.e. function), to the top of the stack.
> 
> Then, after the folder-hooks have all run, the functions are executed one by
> one starting with the top "plate".
> 
> To summarize, the *folder-hooks* are run in the order they occur in your
> muttrc.  But if those hooks use the push command, the pushed *functions* end
> up being run in reverse order (because the last function pushed is on the top
> of the stack).
> 
> This example is fine, because the "." folder-hook runs first setting the
> default macro.  The override for "All Mail" runs second and will overwrite the
> first macro:
> 
># In most folders, pressing L limits to new messages
>folder-hook . "macro index L '~N'"
> 
># In [Gmail]/All Mail, pressing L limits to unread messages
>folder-hook '^\[Gmail\]\/All Mail$' "macro index L '~U'"
> 
> 
> However, in this case I have reversed the order of the folder hooks:
> 
># In [Gmail]/All Mail, show only unread messages
>folder-hook '^\[Gmail\]\/All Mail$' "push ~U"
> 
># By default, show all messages
>folder-hook . "push ~A"
> 
> The push command is run immediately, but the string it pushes is run *after*
> all the folder-hooks finish.  So in the case, you would want the default
> "." to be run first.  Then for "All Mail" you would want the
> "~U" to be run afterwards.
> 
> Sorry for the long post, but I hope that helps a rather confusing topic.
> 

Hello Kevin,

thanks for the expantation, now I got it.

Michael

-- 
BOFH excuse #229:

wrong polarity of neutron flow


Re: Conditional macro?

2018-12-07 Thread Kevin J. McCarthy

On Fri, Dec 07, 2018 at 03:47:05PM +0100, Michael Wagner wrote:

I have tested this and when I change the folder the error message is

.: unknown command


You'll need to use the push command to execute functions inside a folder
hook:
 http://www.mutt.org/doc/manual/#push

However, the push command is a bit tricky in this case.  The pushed 
functions (e.g., ) aren't run immediately: they are stored up and 
run *after* all the folder-hooks are done.


They are stored up in a "stack", like a stack of plates.  Each new push 
adds a "plate" (i.e. function), to the top of the stack.


Then, after the folder-hooks have all run, the functions are executed 
one by one starting with the top "plate".


To summarize, the *folder-hooks* are run in the order they occur in your 
muttrc.  But if those hooks use the push command, the pushed *functions* 
end up being run in reverse order (because the last function pushed is 
on the top of the stack).


This example is fine, because the "." folder-hook runs first setting the 
default macro.  The override for "All Mail" runs second and will 
overwrite the first macro:


   # In most folders, pressing L limits to new messages
   folder-hook . "macro index L '~N'"

   # In [Gmail]/All Mail, pressing L limits to unread messages
   folder-hook '^\[Gmail\]\/All Mail$' "macro index L '~U'"


However, in this case I have reversed the order of the folder hooks:

   # In [Gmail]/All Mail, show only unread messages
   folder-hook '^\[Gmail\]\/All Mail$' "push ~U"

   # By default, show all messages
   folder-hook . "push ~A"

The push command is run immediately, but the string it pushes is run 
*after* all the folder-hooks finish.  So in the case, you would want the 
default "." to be run first.  Then for "All Mail" you 
would want the "~U" to be run afterwards.


Sorry for the long post, but I hope that helps a rather confusing topic.

--
Kevin J. McCarthy
GPG Fingerprint: 8975 A9B3 3AA3 7910 385C  5308 ADEF 7684 8031 6BDA


signature.asc
Description: PGP signature


Re: Conditional macro?

2018-12-07 Thread Michael Wagner
On Dec 06, 2018 at 11:30:52, Paul Hoffman wrote:
> On Thu, Dec 06, 2018 at 05:16:09PM +0200, Alex Sa wrote:
> > Is it possible to set up a macro that would behave differently
> > dependent on the current folder?
> 
> Or, if you just want to limit what's shown when you enter a folder, this 
> might work:
> 
> # By default, show all messages
> folder-hook . "."
> 
> # In [Gmail]/All Mail, show only unread messages
> folder-hook '^\[Gmail\]\/All Mail$' "~U"
Hello Paul,

I have tested this and when I change the folder the error message is

.: unknown command

Is there another variable that I must set?

Tia Michael

-- 
Old MacDonald had a computer with an EIE I/O