Hi Iain,
Yes, this is a good option. I modified my workflow a bit (Spam/Ham are not watched by Sup anymore. The mails should be copied to the Spam/Ham IMAP server for learning and are automatically deleted after 5 days).
Moving the mail from the | pipe in the thread view with
cat > ~/Maildir/SpamAssassin/Spam/cur/$(cat /proc/sys/kernel/random/uuid)
works; The mail is synced to the IMAP server with OfflineIMAP. However, how can I pass the mail below the cursor directly to a pipe command?
The following code causes an error:
class Redwood::InboxMode
def label_spamassassin_spam
t = cursor_thread or return
t.apply_label :spam
t.remove_label :inbox
multi_toggle_new [t]
hide_thread t
pipe_to_process('cat > ~/Maildir/SpamAssassin/Spam/cur/$(cat /proc/sys/kernel/random/uuid)')
regen_text
Index.save_thread t
flush_index
end
end
--- LocalJumpError from thread: main
no block given (yield)
/usr/local/sup/lib/sup/mode.rb:125:in `block in pipe_to_process'
/usr/lib/ruby/2.5.0/open3.rb:205:in `popen_run'
/usr/lib/ruby/2.5.0/open3.rb:95:in `popen3'
/usr/local/sup/lib/sup/mode.rb:107:in `pipe_to_process'
/home/rob/.sup/hooks/startup.rb:8:in `label_spamassassin_spam'
/usr/local/sup/lib/sup/mode.rb:59:in `handle_input'
/usr/local/sup/lib/sup/buffer.rb:222:in `handle_input'
/usr/local/sup/bin/sup:257:in `<module:Redwood>'
/usr/local/sup/bin/sup:76:in `<main>'
Best regards,
Robert
On Wednesday, 8 July 2020 13:53:23 UTC-5, Iain Parris wrote:
Hi Robert,
Excerpts from Robert Winkler's message of 2020-07-08 10:06:55 -0700:
> Thanks, Good hint, Iain!
Thank you!
> I want to move the mails in a second step (yet to be resolved).
>
> Any hints on possible external programs/ scripts for moving mails with a
> particular label to a special /Maildir folder (e.g.
> ~/Maildir/SpamAssassin/Spam)?
Question: do the mails need to be moved, or can they be copied?
(Side note: Sup should de-duplicate copies of mails that appear in more
than one source, i.e., should recognise that it is a duplicate of the
same message, and not show it twice. Or for simplicity, don't tell Sup
to index the SpamAssassin Maildirs!)
If making a copy is sufficient, then you can write the email to a new
file in the appropriate Maildir (since a Maildir is just a collection of
files, with each file being one email). All you need is a random
filename. For example, you could pipe to cat to create with a random
filename (a UUID), using something like:
cat >~/Maildir/SpamAssassin/Spam/$(cat /proc/sys/kernel/random/uuid)
Kind regards,
Iain