Add notmuch

This is in progress and open to changes!
This commit is contained in:
James Nguyen 2017-12-21 22:45:39 -08:00
parent 2ad4f875c2
commit 46e60d4b69
2 changed files with 166 additions and 0 deletions

165
evil-collection-notmuch.el Normal file
View File

@ -0,0 +1,165 @@
;;; evil-collection-notmuch.el --- Bindings for `notmuch'. -*- lexical-binding: t -*-
;; Copyright (C) 2017 James Nguyen
;; Author: James Nguyen <james@jojojames.com>
;; Maintainer: James Nguyen <james@jojojames.com>
;; Pierre Neidhardt <ambrevar@gmail.com>
;; URL: https://github.com/jojojames/evil-collection
;; Version: 0.0.1
;; Package-Requires: ((emacs "25.1"))
;; Keywords: emacs, tools, evil
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;; Bindings for `notmuch'.
;;; Code:
(require 'notmuch nil t)
(require 'evil)
(declare-function notmuch-show-get-tags "notmuch-show")
(declare-function notmuch-show-tag "notmuch-show")
(declare-function notmuch-search-get-tags "notmuch")
(declare-function notmuch-search-tag "notmuch")
(declare-function notmuch-tree-tag "notmuch-tree")
(defun evil-collection-notmuch-show-toggle-delete ()
"Toggle deleted tag for message."
(interactive)
(if (member "deleted" (notmuch-show-get-tags))
(notmuch-show-tag (list "-deleted"))
(notmuch-show-tag (list "+deleted")))
(evil-next-line))
(defun evil-collection-notmuch-search-toggle-delete ()
"Toggle deleted tag for message."
(interactive)
(if (member "deleted" (notmuch-search-get-tags))
(notmuch-search-tag (list "-deleted"))
(notmuch-search-tag (list "+deleted")))
(evil-next-line))
(defun evil-collection-notmuch-tree-toggle-delete ()
"Toggle deleted tag for message."
(interactive)
(if (member "deleted" (notmuch-search-get-tags))
(notmuch-tree-tag (list "-deleted"))
(notmuch-tree-tag (list "+deleted")))
(evil-next-line))
(defun evil-collection-notmuch-setup ()
"Set up `evil' bindings for `notmuch'."
(evil-set-initial-state 'notmuch-show-mode 'normal)
(evil-set-initial-state 'notmuch-search-mode 'normal)
(evil-set-initial-state 'notmuch-hello-mode 'normal)
(evil-define-key 'normal notmuch-common-keymap
"g?" 'notmuch-help
"q" 'notmuch-bury-or-kill-this-buffer
"s" 'notmuch-search
"z" 'notmuch-tree
"c" 'notmuch-mua-new-mail
"gr" 'notmuch-refresh-this-buffer
"gR" 'notmuch-refresh-all-buffers
"Z" 'notmuch-poll-and-refresh-this-buffer
"J" 'notmuch-jump-search)
(evil-define-key 'normal notmuch-hello-mode-map
"g?" 'notmuch-hello-versions
(kbd "TAB") 'widget-forward
(kbd "RET") 'widget-button-press
(kbd "<C-tab>") 'widget-backward)
(evil-define-key 'normal notmuch-show-mode-map
"gd" 'goto-address-at-point
"A" 'notmuch-show-archive-thread-then-next
"S" 'notmuch-show-filter-thread
"K" 'notmuch-tag-jump
"R" 'notmuch-show-reply
"X" 'notmuch-show-archive-thread-then-exit
"Z" 'notmuch-tree-from-show-current-query
"a" 'notmuch-show-archive-message-then-next-or-next-thread
"d" 'evil-collection-notmuch-show-toggle-delete
"H" 'notmuch-show-toggle-visibility-headers
"gj" 'notmuch-show-next-open-message
"gk" 'notmuch-show-previous-open-message
"r" 'notmuch-show-reply-sender
(kbd "x") 'notmuch-show-archive-message-then-next-or-exit
(kbd "C-j") 'notmuch-show-next-thread-show
(kbd "C-k") 'notmuch-show-previous-thread-show
(kbd "C-n") 'notmuch-show-next-message
(kbd "C-p") 'notmuch-show-previous-message
"|" 'notmuch-show-pipe-message
"*" 'notmuch-show-tag-all
"-" 'notmuch-show-remove-tag
"+" 'notmuch-show-add-tag
(kbd "TAB") 'notmuch-show-toggle-message
(kbd "RET") 'notmuch-show-toggle-message)
(evil-define-key 'normal notmuch-tree-mode-map
"g?" (notmuch-tree-close-message-pane-and 'notmuch-help)
"q" 'notmuch-tree-quit
"s" 'notmuch-tree-to-search
"c" (notmuch-tree-close-message-pane-and 'notmuch-mua-new-mail)
"J" (notmuch-tree-close-message-pane-and 'notmuch-jump-search)
"S" 'notmuch-search-from-tree-current-query
"r" (notmuch-tree-close-message-pane-and 'notmuch-show-reply-sender)
"R" (notmuch-tree-close-message-pane-and 'notmuch-show-reply)
"d" 'evil-collection-notmuch-tree-toggle-delete
"K" 'notmuch-tag-jump
(kbd "RET") 'notmuch-tree-show-message
[mouse-1] 'notmuch-tree-show-message
"A" 'notmuch-tree-archive-thread
"a" 'notmuch-tree-archive-message-then-next
"z" 'notmuch-tree-to-tree
"gj" 'notmuch-tree-next-matching-message
"gk" 'notmuch-tree-prev-matching-message
"]" 'notmuch-tree-next-message
"[" 'notmuch-tree-prev-message
(kbd "C-k") 'notmuch-tree-prev-thread
(kbd "C-j") 'notmuch-tree-next-thread
"-" 'notmuch-tree-remove-tag
"+" 'notmuch-tree-add-tag
"*" 'notmuch-tree-tag-thread
"e" 'notmuch-tree-resume-message)
(evil-define-key 'normal notmuch-search-mode-map
"C" 'compose-mail-other-frame
"J" 'notmuch-jump-search
"S" 'notmuch-search-filter
"K" 'notmuch-tag-jump
"o" 'notmuch-search-toggle-order
"Z" 'notmuch-tree-from-search-current-query
"a" 'notmuch-search-archive-thread
"c" 'compose-mail
"d" 'evil-collection-notmuch-search-toggle-delete
"q" 'notmuch-bury-or-kill-this-buffer
"r" 'notmuch-search-reply-to-thread-sender
"t" 'notmuch-search-filter-by-tag
"z" 'notmuch-search-stash-map
[mouse-1] 'notmuch-search-show-thread
"-" 'notmuch-search-remove-tag
"+" 'notmuch-search-add-tag
(kbd "RET") 'notmuch-search-show-thread)
(evil-define-key 'normal notmuch-search-stash-map
"i" 'notmuch-search-stash-thread-id
"q" 'notmuch-stash-query
"g?" 'notmuch-subkeymap-help))
(provide 'evil-collection-notmuch)
;;; evil-collection-notmuch.el ends here

View File

@ -80,6 +80,7 @@
macrostep
man
,@(when evil-collection-setup-minibuffer '(minibuffer))
notmuch
;; occur is in replace.el which was built-in before Emacs 26.
(occur ,(if (<= emacs-major-version 25) "replace" 'replace))
outline