From 0456a1c4b4405da2681296b2250681454637d80f Mon Sep 17 00:00:00 2001 From: William Carroll Date: Fri, 14 Feb 2020 15:38:28 +0000 Subject: [PATCH] Define notmuch KBDs Until I have more opinions about my workflow with notmuch, I will redefine the KBDs from Gmail that I'm comfortable with. While not many KBDs are defined here, evil-collection defines dozens, many of which I find reasonable; those that I disagree with, I've unbound in this commit. Composing emails in notmuch feels similar to writing a commit message with magit. I want to be able to type :x or :wq, but these commands don't DWIM. For magit, I'd like that behavior to be the same as `C-c C-c`; not surprisingly, for notmuch, I'd like the same. I've bound :x to do this for notmuch. I'd like to define a macro that can easily define buffer-local evil-ex commands for particular modes. This should lower the cost of defining evil-ex commands and hopefully convince me to support some of this desired behavior. --- emacs/.emacs.d/wpc/keybindings.el | 44 +++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/emacs/.emacs.d/wpc/keybindings.el b/emacs/.emacs.d/wpc/keybindings.el index c9af5b48d..f756e48db 100644 --- a/emacs/.emacs.d/wpc/keybindings.el +++ b/emacs/.emacs.d/wpc/keybindings.el @@ -21,6 +21,7 @@ (require 'buffer) (require 'display) (require 'device) +(require 'evil-ex) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Configuration @@ -85,5 +86,48 @@ "D0" #'display/disable-4k "D1" #'display/enable-4k)) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; notmuch +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; evil-collection adds many KBDs to notmuch modes. Some of these I find +;; disruptive. +(general-define-key + :states '(normal) + :keymaps '(notmuch-show-mode-map) + "M-j" nil + "M-k" nil + "" #'notmuch-show-previous-thread-show + "" #'notmuch-show-next-thread-show + "e" #'notmuch-show-archive-message-then-next-or-next-thread) + +;; TODO(wpcarro): Consider moving this to a separate module +(defun evil-ex-define-cmd-local (cmd f) + "Define CMD to F locally to a buffer." + (unless (local-variable-p 'evil-ex-commands) + (setq-local evil-ex-commands (copy-alist evil-ex-commands))) + (evil-ex-define-cmd cmd f)) + +;; TODO(wpcarro): Support a macro that can easily define evil-ex commands for a +;; particular mode. +;; Consumption: +;; (evil-ex-for-mode 'notmuch-message-mode +;; "x" #'notmuch-mua-send-and-exit) + +(add-hook 'notmuch-message-mode-hook + (lambda () + (evil-ex-define-cmd-local "x" #'notmuch-mua-send-and-exit))) + +;; For now, I'm mimmicking Gmail KBDs that I have memorized and enjoy +(general-define-key + :states '(normal) + :keymaps '(notmuch-search-mode-map) + "e" #'notmuch-search-archive-thread) + +(general-define-key + :states '(normal) + :prefix "" + "gn" #'notmuch) + (provide 'keybindings) ;;; keybindings.el ends here