* Ed Blackman <e...@edgewood.to> [2014-02-26 20:46]:
> On Wed, Feb 26, 2014 at 04:45:00PM +0100, Peter P. wrote:
> >   folder-hook . 'macro pager d "<save-message>=Trash \r"
> [...]
> >Is there a way to incoorporate the status/flag of a message as
> >conditional for the above key binding to only allow saving to trash if
> >the message is not marked as 'deleted'?
> 
> You might want to investigate the 'trash' patch, which is commonly
> already applied to packaged versions of mutt.
> http://cedricduval.free.fr/mutt/patches/#trash

Thanks Ed! It seems my version of mutt (1.5.21) has the
        features/trash-folder
compiled in, yet I didn't yet set the respective variable in the
config file. Will test that and get back to this list if there is
still questions open. Thank you also for hacking out the option below,
which seems very cool as well!

best, Peter

> If you don't have the patch and don't want to build mutt to apply
> it, there are not a lot of good options.  The main problem is
> there's no way I know of to do general conditional logic ("if
> message isn't marked as deleted, save to trash, otherwise do
> nothing") directly in a macro.
> 
> The only conditional logic I know of is tag-prefix-cond, but I can't
> think of a way to use that for your end.
> 
> You can use backticks to move some of the conditional logic to a
> shell script.  You would need a macro that would pipe a message to
> save it in a known location, then use :push with backticks to call a
> program that read the email in that location, then either emitted
> the command to save the message or a noop depending on whether the
> email's Message-Id was in a cache.
> 
> It would look something like this:
> 
> macro index d '<pipe-message>cat > /tmp/message.txt<enter>\
> :push `/path/to/script.sh`<enter>' "Save to trash folder"
> 
> /path/to/script.sh would:
> 1) read /tmp/message.txt and extract the Message-Id
> 2) check to see if the Message-Id was in the cache
> 3) if not, print '<save-message>=Trash<enter><enter>' and add the Id
> to the cache
> 
> If the message was in the cache, the script would do nothing,
> causing the macro to do nothing further.
> 
> Pretty convoluted, and race-prone since you have to save the message
> in a fixed location.  There might be further tricks to remove that
> particular limitation, but I've procrastinated enough today.
> 
> -- 
> Ed Blackman
Thanks Ed

Reply via email to