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

<limit>.<Enter>: 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., <limit>) 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 '<limit>~N<Enter>'"

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


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 <limit>~U<Enter>"

   # By default, show all messages
   folder-hook . "push <limit>~A<Enter>"

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 "<limit>.<Enter>" to be run first. Then for "All Mail" you would want the "<limit>~U<Enter>" 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

Attachment: signature.asc
Description: PGP signature

Reply via email to