index rss mastodon twitter github linkedin email
Álvaro Ramírez
sponsor

Álvaro Ramírez

10 November 2018 Faster junk mail deletion with mu4e

It's been roughly 5 months since my mu4e email migration. Happy with my choice. Mu4e is awesome.

I now have 4 email accounts managed by mu4e, and unfortunately receiving lots of junk mail.

I regularly peek at junk folders for false positives and delete junk email permanently. I've been wanting a quick way to glance at junk mail and easily delete page by page.

Deleting emails page by page is not supported in mu4e by default. Fortunately, this is Emacs and we can change that™.

There's a handy package by Roland Walker called window-end-visible. We can use it to select mu4e emails by page and subsequently glue it all together to enable deleting emails by page.

(require 'mu4e)
(require 'window-end-visible)

(defun ar/mu4e-delete-page ()
  (interactive)
  (set-mark (window-start))
  (goto-char (window-end-visible))
  (activate-mark)
  (mu4e-headers-mark-for-trash)
  (mu4e-mark-execute-all t)
  (deactivate-mark)
  (goto-char (window-start)))

I'm a use-package fan, so I use it to bind the "v" key to delete visible emails (by page).

(use-package mu4e
  :bind (:map mu4e-headers-mode-map
         ("v" . ar/mu4e-delete-page))

delete-junk.gif