aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorÓscar Nájera <hi@oscarnajera.com>2022-04-16 13:02:31 +0200
committerÓscar Nájera <hi@oscarnajera.com>2022-04-16 13:02:31 +0200
commit044b850f4b0df05f5b0cd95292acc7c34aecebba (patch)
tree95bba6b6a8130e9f48e646a99b218a3007d5fbb5 /config
parent131898a8e22a3ba1fcf52ae8a8e67d512feabf58 (diff)
downloaddotfiles-044b850f4b0df05f5b0cd95292acc7c34aecebba.tar.gz
dotfiles-044b850f4b0df05f5b0cd95292acc7c34aecebba.tar.bz2
dotfiles-044b850f4b0df05f5b0cd95292acc7c34aecebba.zip
Set spam on notmuch-show messages
Diffstat (limited to 'config')
-rw-r--r--config/doom/config.org21
1 files changed, 20 insertions, 1 deletions
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."