Skip to content

Instantly share code, notes, and snippets.

@mntmn
Created May 2, 2019 16:08
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 mntmn/2b76b2cf8b3e424856d366b050706a83 to your computer and use it in GitHub Desktop.
Save mntmn/2b76b2cf8b3e424856d366b050706a83 to your computer and use it in GitHub Desktop.
Notmuch workflow related snippets of emacs init.el
; fetch-mail function
(defun fetch-mail ()
"Launches ~/bin/fetch-mail"
(interactive)
(shell-command "fetch-mail")
(dolist (win (window-list))
(when (string= (buffer-name (window-buffer win)) "*Shell Command Output*")
(delete-window win)
;(kill-buffer "*Shell Command Output*")
))
(notmuch-jump-search)
)
; keyboard shortcuts
(global-set-key (kbd "<f2>") (lambda() (interactive) (notmuch)))
(global-set-key (kbd "<f3>") (lambda() (interactive) (fetch-mail)))
(define-key notmuch-search-mode-map "f"
(lambda ()
"toggle flagged tag for message"
(interactive)
(if (member "flagged" (notmuch-search-get-tags))
(notmuch-search-tag (list "-flagged"))
(notmuch-search-tag (list "+flagged")))))
(define-key notmuch-search-mode-map "d"
(lambda ()
"toggle deleted tag for message"
(interactive)
(if (member "deleted" (notmuch-search-get-tags))
(notmuch-search-tag (list "-deleted"))
(notmuch-search-tag (list "+deleted")))))
; notmuch hello tweak
(add-hook 'notmuch-hello-refresh-hook
(lambda ()
(if (eq (point) (point-min))
(progn (search-forward "inbox" nil t)
;; todo move one word back
(backward-char 1)
))))
(setq notmuch-show-all-tags-list t)
; productivity searches
(setq-default notmuch-saved-searches
(quote
((:name "inbox" :query "(tag:flagged OR tag:unread) date:3months.." :sort-order newest-first :key "1")
(:name "inbox2" :query "tag:inbox date:2months.." :sort-order newest-first :key "2")
(:name "notes" :query "from:lukas@mntmn.com to:lukas@mntmn.com" :sort-order newest-first :key "n")
(:name "starred" :query "tag:flagged" :sort-order newest-first :key "f")
(:name "sent" :query "tag:sent" :sort-order newest-first :key "s"))))
(setq notmuch-search-oldest-first nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment