Re: Conditional macro?
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?
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?
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
Re: Conditional macro?
Paul, that's just brilliant, thank you :) folder-hooks were always somehow overlooked by me but now I see the potential :) Thanks once again! -- Alex On 12/6/18, 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? > > Yes, using a folder hook to bind a key (or key sequence) to different > actions based on the folder. For example: > > # 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'" > > 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" > > Does that help? I may have misunderstood what you're trying to do. > > Paul. > > -- > Paul Hoffman > -- -- Alex
Re: Conditional macro?
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? Yes, using a folder hook to bind a key (or key sequence) to different actions based on the folder. For example: # 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'" 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" Does that help? I may have misunderstood what you're trying to do. Paul. -- Paul Hoffman
Re: Conditional macro?
Thanks, Francesco! It's a bit of re-write for all the "changing folders" macroses that I have previously set up but it seems like this trick indeed can help me :) Thanks once again! -- Alex On 12/6/18, Francesco Ariis wrote: > Hello Alex, > > 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? > > Never tried it myself, but I recall this: > > https://gitlab.com/muttmua/mutt/wikis/ConfigTricks > > (specifically, the "(ab)use "macros" as variables."; maybe you can > "set" the variable once you enter a folder and then use it > with your macro). > > Maybe it can be of help in your case? > -F > -- -- Alex
Re: Conditional macro?
Hello Alex, 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? Never tried it myself, but I recall this: https://gitlab.com/muttmua/mutt/wikis/ConfigTricks (specifically, the "(ab)use "macros" as variables."; maybe you can "set" the variable once you enter a folder and then use it with your macro). Maybe it can be of help in your case? -F
Conditional macro?
Hi! Is it possible to set up a macro that would behave differently dependent on the current folder? Let's say I want to to limit messages in the "[Gmail]/All Mail" folder to display only the new ones. So, if I'm not in "All Mail", that would be something like this: =[Gmail]/All Mail~U However, If I'm IN this "All Mail" folder, then, of course, I don't want to re-read all these thousands of emails again, and want to execute "~U" immediately. Is it doable? :) Thanks! -- Alex
conditional macro
I set the following macro via a folder-hook for my mailinglist folders: macro index S tag-pattern~d2w\nuntag-pattern~F\ntag-prefixsave-message\n Alte Mails nach _r It should move old messages to an archive-folder, an apropriate save-hook is set. It is working fine, if there is at least one message to move. The problem is if there is no message tag, mutt executes save-message for the currently selected message. How can I stop the macro, if there is no tagged message? Thanks Nicolas
Re: conditional macro
Nicolas -- ...and then Nicolas Rachinsky said... % I set the following macro via a folder-hook for my mailinglist ... % The problem is if there is no message tag, mutt executes % save-message for the currently selected message. % % How can I stop the macro, if there is no tagged message? At this point you can't. Check the archives; it's come up many times before. % % Thanks % Nicolas :-D -- David T-G * It's easier to fight for one's principles (play) [EMAIL PROTECTED] * than to live up to them. -- fortune cookie (work) [EMAIL PROTECTED] http://www.justpickone.org/davidtg/Shpx gur Pbzzhavpngvbaf Qrprapl Npg! msg20340/pgp0.pgp Description: PGP signature