From 044b850f4b0df05f5b0cd95292acc7c34aecebba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93scar=20N=C3=A1jera?= Date: Sat, 16 Apr 2022 13:02:31 +0200 Subject: Set spam on notmuch-show messages --- config/doom/config.org | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'config') diff --git a/config/doom/config.org b/config/doom/config.org index c10375d..4a057db 100644 --- a/config/doom/config.org +++ b/config/doom/config.org @@ -226,6 +226,7 @@ this new window. ("d" . notmuch-show-delete-message) ("D" . notmuch-show-delete-thread-then-exit) ("i" . notmuch-show-tag-spam) + ("cb" . on/notmuch-spam-test) ("cr" . org-store-link) ) :config @@ -269,10 +270,28 @@ this new window. (interactive) (notmuch-show-tag-message (notmuch-toggle-tag "deleted" (notmuch-show-get-tags)))) + (defun on/bogofilter (&rest args) + "Call bogofilter on current notmuch-show-file with ARGS." + (let ((msg-file (notmuch-show-get-filename))) + (with-temp-buffer + (apply #'call-process "bogofilter" msg-file t nil args) + (message (string-trim (buffer-string)))))) + + (defun on/notmuch-spam-test () + "Evaluate spaminess of message." + (interactive) + (on/bogofilter "-v")) + + (defun on/bogofilter-set-spam (spam-p) + "Set spam or ham depending according to SPAM-P." + (on/bogofilter "-v" (if spam-p "-s" "-n"))) + (defun notmuch-show-tag-spam () "Tag spam on current message if already marked as spam undo." (interactive) - (notmuch-show-tag-message (notmuch-toggle-tag "spam" (notmuch-show-get-tags)))) + (let ((tag (notmuch-toggle-tag "spam" (notmuch-show-get-tags)))) + (notmuch-show-tag-message tag) + (on/bogofilter-set-spam (string-prefix-p "+" tag)))) (defun notmuch-show-delete-thread-then-exit () "Delete all messages in the current buffer, then exit back to search results." -- cgit v1.2.3