/notmuch-x

A set of custom extensions for notmuch-emacs

Primary LanguageEmacs Lisp

notmuch-x

This package provides a set of custom extensions for the notmuch Emacs-based interface.

Installation

Clone this repo and add it to your load-path:

(add-to-list 'load-path "/path/to/notmuch-x")
(require 'notmuch-x)

Or, with use-package + straight.el:

(use-package notmuch-x
  :straight (notmuch-x :host github :repo "bcardoso/notmuch-x"))

Usage

Start notmuch with notmuch-x-run-notmuch: it will enable both the notmuch-x-auto-update-mode, to periodically find and import any new messages, and the mode-line indicator notmuch-x-indicator-mode. The relevant customizable variables are accessible through the customize interface:

  • M-x customize-group RET notmuch-x

Example configuration

Below are my current notmuch-x configuration and keybindings.

(use-package notmuch-x
  :straight (notmuch-x :host github :repo "bcardoso/notmuch-x")
  :after notmuch
  :bind (("C-c m"            . notmuch-x-run-notmuch)
         ("C-c M"            . notmuch-x-update-dwim)
         ("C-x m"            . notmuch-mua-new-mail)
         (:map notmuch-search-mode-map
               ("G"          . notmuch-x-update-dwim)
               ("Q"          . notmuch-x-kill-all-search-buffers)
               ("S"          . notmuch-x-edit-current-search)
               ("U"          . notmuch-unthreaded)
               ("u"          . my/notmuch-tag-toggle-unread)
               ("f"          . my/notmuch-tag-toggle-flagged)
               ("a"          . my/notmuch-tag-archived)
               ("T"          . my/notmuch-tag-todo)
               ("i"          . my/notmuch-tag-inbox)
               ("d"          . my/notmuch-tag-trash))
         (:map notmuch-show-mode-map
               ("<C-return>" . notmuch-x-toggle-thread-visibility)
               ("<RET>"      . notmuch-x-toggle-message-or-browse-url)
               ("<tab>"      . notmuch-x-next-button-or-link)
               ("<backtab>"  . notmuch-x-previous-button-or-link)
               ("n"          . notmuch-show-next-message)
               ("N"          . notmuch-show-next-open-message)
               ("p"          . notmuch-show-previous-message)
               ("P"          . notmuch-show-previous-open-message)
               ("o"          . notmuch-x-view-part-in-browser)
               ("u"          . my/notmuch-tag-toggle-unread)
               ("f"          . my/notmuch-tag-toggle-flagged)
               ("a"          . my/notmuch-tag-archived)
               ("T"          . my/notmuch-tag-todo)
               ("i"          . my/notmuch-tag-inbox)
               ("d"          . my/notmuch-tag-trash)))
  :config
  ;; Alternate format for notmuch-search fields
  (setq notmuch-x-search-date-format "%F %R")
  (setq notmuch-x-search-truncate-subject-width 68)
  (notmuch-x-search-alt-format-mode +1)

  (defun my/notmuch-tag-toggle-unread ()
    "Toggle 'unread' tag."
    (interactive)
    (notmuch-x-tag-toggle "unread"))

  (defun my/notmuch-tag-toggle-flagged ()
    "Toggle 'flagged' tag."
    (interactive)
    (notmuch-x-tag-toggle "flagged"))

  (defun my/notmuch-tag-archived ()
    "Tag thread as 'archived'."
    (interactive)
    (notmuch-x-tag-thread '("+archived" "-inbox" "-todo" "-trash" "-unread") t))

  (defun my/notmuch-tag-todo ()
    "Tag selected message(s) as 'todo'."
    (interactive)
    (notmuch-x-tag '("+todo" "+inbox" "-archived" "-trash")))

  (defun my/notmuch-tag-inbox ()
    "Tag selected message(s) as 'inbox'."
    (interactive)
    (notmuch-x-tag '("+inbox" "-trash" "-archived")))

  (defun my/notmuch-tag-trash ()
    "Tag selected message(s) as 'trash'."
    (interactive)
    (notmuch-x-tag '("+trash" "-inbox" "-archived" "-todo" "-unread"))))