From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6846438166349479936 Date: Wed, 8 Jul 2020 10:06:55 -0700 (PDT) From: Robert Winkler To: The Sup email client Message-Id: <5048bacc-c026-45c3-b145-52226916491co@googlegroups.com> In-Reply-To: <1594076857-sup-7295@ceres> References: <7c75d917-b99e-4e95-af72-d308acfcb7ado@googlegroups.com> <1594076857-sup-7295@ceres> Subject: Re: [sup] SpamAssassin (Spam/Ham) support for Sup MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_966_1670226122.1594228015991" X-Google-Token: EK_6l_gFhZTwG2ENvDM0 X-Google-IP: 177.248.130.232 ------=_Part_966_1670226122.1594228015991 Content-Type: multipart/alternative; boundary="----=_Part_967_1432329895.1594228015992" ------=_Part_967_1432329895.1594228015992 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 > ------=_Part_967_1432329895.1594228015992 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
Thanks, Good hint, Iain!

The '|'= ; is an interesting option, but I did not get it working for direct file op= erations. 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:
<= div>
class Redwood<= /span>::InboxMode
=C2=A0 def label_spamassassin_spam=C2=A0 =C2=A0t =3D= cursor_thread or return
=C2=A0 =C2= =A0t
.apply_label
:spam
=C2=A0 =C2=A0m= ulti_toggle_new [t]
=C2=A0 =C2=A0rege= n_text
=C2=A0 =C2=A0
Index.s= ave_thread t
=C2=A0 =C2=A0flush_index
=C2=A0
end
end


class Redwood::I= nboxMode=C2=A0 d= ef label_s= pamassassin_ham
=C2=A0 =C2=A0t
=3D cursor_thread or return
=C2=A0 =C2=A0t
.apply_label :ham=C2=A0 =C2=A0regen_text
=C2=A0 =C2=A0
Index.save_thread t
=C2=A0 =C2=A0flush_index
=C2=A0 end
end


class Redwood::SearchResultsMode
=C2=A0
def label_spamassassin_spam
=C2=A0 =C2=A0t
=3D cursor_thread or return
=C2=A0 =C2=A0t
.apply_label :spam
=C2=A0 =C2=A0multi_toggle_new
[t]
=C2=A0 =C2=A0regen_text
=C2=A0 =C2=A0
Index.save_thread t
=C2=A0 =C2=A0flus= h_index
=C2=A0
end
end


=
class Redwood::SearchResultsMode
=C2=A0
def label_spamassassin_ham
=C2=A0 = =C2=A0t
= =3D cursor= _thread or= return

=C2=A0 =C2=A0t.apply_label :
ham
=C2=A0 =C2=A0regen_text<= br>=C2=A0 =C2=A0
Index.save_thr= ead t
=C2=A0 =C2=A0flush_index
=C2=A0
end
end


keybindings.rb:

modes[= "inbox-mode"].keymap= .add :label_spamassassin_spam<= /span>, "Label as SpamAssassin = Spam"= , <= span style=3D"color: #080;" class=3D"styled-by-prettify">'s'=
modes
<= span style=3D"color: #660;" class=3D"styled-by-prettify">["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_spamas= sassin_ham= , <= span style=3D"color: #080;" class=3D"styled-by-prettify">"Label as Spa= mAssassin Ham",= 'h= 9;

I want to move the mails in a second step (y= et to be resolved).

Any hints on possible external= programs/ scripts for moving mails with a particular label to a special /M= aildir folder (e.g. ~/Maildir/SpamAssassin/Spam)?

= Best regards,=C2=A0

Robert=C2=A0

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=20
> IMAP Folder?
>=20
> Ideally, I would just tag them with ",s" for Spam and &q= uot;,h" as Ham, and when=20
> 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 thi= s
functionality. For a full list of hooks, launch sup with "--list-h= ooks".
(See <https://github.com/sup-heliotrope/sup/wiki/Hooks>.)

Are you looking to operate on threads (groups of messages) or individua= l
emails? For example, existing hook "mark-as-spam" operates on= an entire
thread, not an individual message - which I suspect is probably not wha= t
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 allow= s 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 f= ed 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 met= hods, e.g.,
=C2=A0 send_to_sa_ham and send_to_sa_spam. For inspiration, see
=C2=A0 Redwood::ThreadViewMode#pipe_message (in file
=C2=A0 lib/sup/modes/thread_view_mode.rb).

- "keybindings" hook: To bind keys to the new functions.

For inspiration from another user, see:
<ht= tps://christop.club/2014/01/19/sup/#hooks> - this shows an exam= ple 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
------=_Part_967_1432329895.1594228015992-- ------=_Part_966_1670226122.1594228015991--