Discussions of development and use of the Sup email client
 help / color / mirror / Atom feed
From: Robert Winkler <robert.winkler.mail@gmail.com>
To: The Sup email client <supmua@googlegroups.com>
Subject: Re: [sup] SpamAssassin (Spam/Ham) support for Sup
Date: Wed, 8 Jul 2020 10:06:55 -0700 (PDT)	[thread overview]
Message-ID: <5048bacc-c026-45c3-b145-52226916491co@googlegroups.com> (raw)
In-Reply-To: <1594076857-sup-7295@ceres>


[-- Attachment #1.1: Type: text/plain, Size: 4055 bytes --]

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 <https://github.com/sup-heliotrope/sup/wiki/Hooks>.) 
>
> 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: 
> <https://christop.club/2014/01/19/sup/#hooks> - 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 
>

[-- Attachment #1.2: Type: text/html, Size: 16848 bytes --]

  reply	other threads:[~2020-07-08 17:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-06 18:36 Robert Winkler
2020-07-06 23:27 ` [sup] " Iain Parris
2020-07-08 17:06   ` Robert Winkler [this message]
2020-07-08 18:53     ` Iain Parris
2020-07-09 22:20       ` Robert Winkler
2020-07-10 20:26         ` Iain Parris
2020-07-10 20:29           ` Iain Parris
2020-07-10 21:58             ` Robert Winkler
2020-07-11 13:48               ` Iain Parris
2020-07-24 10:38               ` Robert Winkler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5048bacc-c026-45c3-b145-52226916491co@googlegroups.com \
    --to=robert.winkler.mail@gmail.com \
    --cc=supmua@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox