Conditional macro?

Paul Hoffman nkuitse at nkuitse.com
Thu Dec 6 16:30:52 UTC 2018


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

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

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 . "<limit>.<Enter>"

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

Does that help?  I may have misunderstood what you're trying to do.

Paul.

-- 
Paul Hoffman <nkuitse at nkuitse.com>


More information about the Mutt-users mailing list