Macro variable with current folder name?
Dennis Preiser
dp-mutt at d--p.de
Sat Mar 11 17:15:14 UTC 2023
On Sat, Mar 11, 2023 at 09:19:22AM -0500, José María Mateos wrote:
> I have this macro:
>
> macro index,pager G "!offlineimap -o -l /tmp/offlineimap.log\n" "Retrieve new IMAP messages"
>
> It works well, but I typically use only for =INBOX, so checking all the
> folders (the default behaviour) is a waste. I've been trying to find if
> there's any way to pass only the current folder name in the macro. Something
> like
>
> macro index,pager G "!offlineimap -o -l /tmp/offlineimap.log -f $FOLDER_NAME\n"
>
> I haven't been able to find anything like that. I've found some old
> solutions online[1] but they look slightly cumbersome; I'd like to set up
> just one macro, not several (I could have one for the INBOX and another one
> for all folders, though, but still, it's two macros). Also, they're old
> responses, and mutt has changed since then.
There is a "current mailbox" shortcut '^'. However, this expands only
for mailbox variables. You could use $record temporarily for the macro
and then set it back to the old value (here with echo to see what ends
up in the variable):
folder-hook . 'set my_record=$record; \
set record=^; \
macro index,pager G "<enter-command>echo $record<enter>"; \
set record=$my_record'
Dennis
More information about the Mutt-users
mailing list