Thanks, Good hint, Iain! The '|' is an interesting option, but I did not get it working for direct file operations. Instead, I am working on a different approach: Usually, the real Spam and real Ham emails can be identified already in the Inbox view and labeled: startup.rb: class Redwood::InboxMode def label_spamassassin_spam t = cursor_thread or return t.apply_label :spam multi_toggle_new [t] regen_text Index.save_thread t flush_index end end class Redwood::InboxMode def label_spamassassin_ham t = cursor_thread or return t.apply_label :ham regen_text Index.save_thread t flush_index end end class Redwood::SearchResultsMode def label_spamassassin_spam t = cursor_thread or return t.apply_label :spam multi_toggle_new [t] regen_text Index.save_thread t flush_index end end class Redwood::SearchResultsMode def label_spamassassin_ham t = cursor_thread or return t.apply_label :ham regen_text Index.save_thread t flush_index end end keybindings.rb: modes["inbox-mode"].keymap.add :label_spamassassin_spam, "Label as SpamAssassin Spam", 's' modes["inbox-mode"].keymap.add :label_spamassassin_ham, "Label as SpamAssassin Ham", 'h' modes["search-results-mode"].keymap.add :label_spamassassin_spam, "Label as SpamAssassin Spam", 's' modes["search-results-mode"].keymap.add :label_spamassassin_ham, "Label as SpamAssassin Ham", 'h' 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)? Best regards, Robert On Monday, 6 July 2020 18:27:13 UTC-5, Iain Parris wrote: > > Hi Robert, > > Excerpts from Robert Winkler's message of 2020-07-06 11:36:45 -0700: > > However: How could I mark mails as Spam/ Ham and move them into a > separate > > IMAP Folder? > > > > Ideally, I would just tag them with ",s" for Spam and ",h" as Ham, and > when > > synching, the mails are moved (or better copied?) for training. > > I understand what you are aiming for. This is an interesting question. > :-) > > Sup has hooks, and I believe these could be used to extend Sup with this > functionality. For a full list of hooks, launch sup with "--list-hooks". > (See .) > > Are you looking to operate on threads (groups of messages) or individual > emails? For example, existing hook "mark-as-spam" operates on an entire > thread, not an individual message - which I suspect is probably not what > you're looking for > > Instead, to operate on individual messages (which I think is what > SpamAssassin would prefer), I think creating a custom variant inspired > by the existing "pipe_message" method may succeed. This allows you to > pipe an entire email message to any arbitrary *nix command (e.g., could > be used to write the message contents to a new file in either a special > "ham" or "spam" directory, which in turn could be fed into sa-learn). > > (For a demonstration of pipe_message, open a message in Sup, then type > "|" and enter, then: "wc -l" and enter. This calls "wc -l" with the > message contents, and returns a line count.) > > So I think it would be possible to accomplish what you are looking for > with two hooks: > > - "startup" hook: Extend Redwood::ThreadViewMode with new methods, e.g., > send_to_sa_ham and send_to_sa_spam. For inspiration, see > Redwood::ThreadViewMode#pipe_message (in file > lib/sup/modes/thread_view_mode.rb). > > - "keybindings" hook: To bind keys to the new functions. > > For inspiration from another user, see: > - this shows an example of > extending Sup (Redwood) classes with new methods, and binding keys to > these new methods. > > I know this is only a very rough outline of a possible solution - but > does this make sense, and sound like a path you may be interested in? > > Kind regards, > Iain >