Skip to content

Instantly share code, notes, and snippets.

@tbielawa
Created March 7, 2012 22:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tbielawa/1996899 to your computer and use it in GitHub Desktop.
Save tbielawa/1996899 to your computer and use it in GitHub Desktop.
Non-interactive tagging in notmuch-search-mode updated for notmuch-0.12
(defun notmuch-search-tag-and-advance (&rest tags)
"Apply a tag or set of tags to the current thread.
Shortcut to simplify applying tags in search mode. Targeted for
use in key-bound functions. Advances to the next thread after
applying the tags."
(mapc 'notmuch-search-tag-thread tags)
(notmuch-search-next-thread))
;; Simple use case, "mark-as-read" while on a search buffer
(defun notmuch-search-mark-as-read ()
"In search mode, remove the unread tag from a thread"
(interactive)
(notmuch-search-tag-and-advance "-unread"))
;; The tag-and-advance function accepts multiple tags at once
(defun notmuch-search-mark-as-spam ()
"Mark this thread as spam"
(interactive)
(notmuch-search-tag-and-advance "-unread" "-inbox" "+spam"))
;; Two more functions I use frequently
(defun notmuch-search-add-todo ()
"Add 'TODO' tag when in search-mode"
(interactive)
(notmuch-search-tag-and-advance "+TODO"))
(defun notmuch-search-remove-todo ()
"Remove a 'TODO' tag in search mode"
(interactive)
(notmuch-search-tag-and-advance "-TODO"))
;; Examples of how to bind the "mark-as-read" function to the "u" key
(define-key notmuch-search-mode-map "u" 'notmuch-search-mark-as-read)
;; And how to bind +TODO/-TODO to (Shift-)F9
(define-key notmuch-search-mode-map (kbd "S-<f9>") 'notmuch-search-remove-todo)
(define-key notmuch-search-mode-map (kbd "<f9>") 'notmuch-search-add-todo)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment