commit 12d98f4f3d9d0bffcf8b8de2597673bf5c7ce9f0
parent d4b2db87d1066496444a1fbfa65fff8c503f54a4
Author: Anders Damsgaard <anders.damsgaard@geo.au.dk>
Date: Tue, 8 Mar 2016 11:00:57 -0800
call bogofilter from imapfilter, classify msgs from mutt
Diffstat:
3 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/.imapfilter/riseup.lua b/.imapfilter/riseup.lua
@@ -38,8 +38,6 @@ mailboxes, folders = account:list_all()
mailboxes, folders = account:list_subscribed()
-
-
-------------------
-- Mailbox rules --
-------------------
@@ -54,6 +52,26 @@ mailboxes, folders = account:list_subscribed()
--results = account.INBOX:is_new()
+--------------------
+-- Spam filtering --
+--------------------
+all = account.INBOX:select_all()
+spam = Set {}
+unsure = Set {}
+for _, msg in ipairs(all) do
+ mbox, uid = unpack(msg)
+ text = mbox[uid]:fetch_message()
+ flag = pipe_to('bogofilter', text)
+ if (flag == 0) then
+ table.insert(spam, msg)
+ elseif (flag == 2) then
+ table.insert(unsure, msg)
+ end
+end
+account['INBOX']:move_messages(account['Junk'], spam)
+account['INBOX']:copy_messages(account['Junk/unsure'], unsure)
+
+
-- Debian announcements list --
addr = 'debian-announce@lists.debian.org'
mailbox = 'debian-announce'
diff --git a/.mutt/muttrc b/.mutt/muttrc
@@ -173,5 +173,14 @@ set my_index_format_post=' (%4.4c) %?M?<%M> ?%s"'
folder-hook .*[sS]ent.* "$my_index_format_pre"t"$my_index_format_post"
folder-hook ! .*[sS]ent.* "$my_index_format_pre"F"$my_index_format_post"
+# mark as spam
+macro index,pager S "<enter-command>unset wait_key<enter>\
+<pipe-entry>bogofilter -l -s<enter>\
+<enter-command>set wait_key<enter>\
+<save-message>=Junk<enter>" "mark as spam"
+macro index,pager H "<enter-command>unset wait_key<enter>\
+<pipe-entry>bogofilter -l -n<enter>\
+<enter-command>set wait_key<enter>J" "mark as ham (non-spam)"
+
# Get mutt to display its version on startup.
push <show-version>
diff --git a/bin/install_debian_pkgs.sh b/bin/install_debian_pkgs.sh
@@ -9,6 +9,6 @@ sudo apt-get install vim tmux git zsh i3 exuberant-ctags haskell-platform \
rxvt-unicode-256color texlive cmake sshfs paraview python-numpy \
python-scipy python-matplotlib ipython mplayer zathura okular python-pip \
dunst latexmk texlive-full screenfetch i3blocks torbrowser-launcher \
- vim-nox w3m
+ vim-nox w3m imapfilter bogofilter
sudo gem install tmuxinator