summaryrefslogtreecommitdiff
path: root/modes/mu4e-conversation
diff options
context:
space:
mode:
authorJustin Burkett <justin@burkett.cc>2018-07-12 15:05:50 -0400
committerJames N <james@jojojames.com>2019-10-09 19:41:45 -0700
commit95dad4c734ae3d3811c05b259eea15ac4f3cb5c5 (patch)
treed2e8bad926a11d2665ce3c86ca986e0f1447a23c /modes/mu4e-conversation
parent34d515e99e911f368b335bbccc026b71b42a9821 (diff)
Use subdirectories for setup files (+READMEs)
Move setup files into subdirectories. Move mode directories to modes subdir. This will make it easy to specify a recipe in melpa that maintains the directory structure. Add interactive functions to jump to .el and README files See #170
Diffstat (limited to 'modes/mu4e-conversation')
-rw-r--r--modes/mu4e-conversation/evil-collection-mu4e-conversation.el75
1 files changed, 75 insertions, 0 deletions
diff --git a/modes/mu4e-conversation/evil-collection-mu4e-conversation.el b/modes/mu4e-conversation/evil-collection-mu4e-conversation.el
new file mode 100644
index 0000000..8d72bc1
--- /dev/null
+++ b/modes/mu4e-conversation/evil-collection-mu4e-conversation.el
@@ -0,0 +1,75 @@
+;;; evil-collection-mu4e-conversation.el --- Evil bindings for mu4e-conversation -*- lexical-binding: t -*-
+
+;; Copyright (C) 2018 Pierre Neidhardt <mail@ambrevar.xyz>
+
+;; Author: Pierre Neidhardt <mail@ambrevar.xyz>
+;; Maintainer: James Nguyen <james@jojojames.com>
+;; Pierre Neidhardt <mail@ambrevar.xyz>
+;; URL: https://github.com/emacs-evil/evil-collection
+;; Version: 0.0.1
+;; Package-Requires: ((emacs "24.4") (evil "1.2.10"))
+;; Keywords: evil, mu4e, tools
+
+;; This file 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, or (at your
+;; option) any later version.
+;;
+;; This file 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.
+;;
+;; For a full copy of the GNU General Public License
+;; see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;; Evil bindings for mu4e-conversation.
+
+;;; Code:
+
+(require 'evil-collection)
+(require 'mu4e-conversation nil t)
+
+(defconst evil-collection-mu4e-conversation-maps '(mu4e-conversation-map
+ mu4e-conversation-thread-map))
+
+(defvar evil-collection-mu4e-conversation--local-map-p nil
+ "Non-nil if last position was on a local-map property.")
+
+(defun evil-collection-mu4e-conversation--switch ()
+ "Re-compute the bindings if point has moved between the thread
+ area and the composition area."
+ (let ((local-map-here (get-text-property (point) 'local-map)))
+ (when (or (and evil-collection-mu4e-conversation--local-map-p
+ (not local-map-here))
+ (and (not evil-collection-mu4e-conversation--local-map-p)
+ local-map-here))
+ (evil-normalize-keymaps))
+ (setq evil-collection-mu4e-conversation--local-map-p local-map-here)))
+
+(defun evil-collection-mu4e-conversation--update-local-map ()
+ (setq evil-collection-mu4e-conversation--local-map-p (get-text-property (point) 'local-map))
+ (evil-normalize-keymaps)
+ (add-hook 'post-command-hook 'evil-collection-mu4e-conversation--switch nil t))
+
+;;;###autoload
+(defun evil-collection-mu4e-conversation-setup ()
+ "Set up `evil' bindings for `mu4e-conversation'."
+ ;; Evil does not update its current keymap state when it the point hits a
+ ;; local-map property is used. See
+ ;; https://github.com/emacs-evil/evil/issues/301. Thus we force the update
+ ;; with a technique similar to what `org~mu4e-mime-switch-headers-or-body'
+ ;; does.
+ (add-hook 'mu4e-conversation-hook 'evil-collection-mu4e-conversation--update-local-map)
+ (evil-collection-define-key 'normal 'mu4e-conversation-map
+ " " 'evil-scroll-page-down
+ (kbd "S-SPC") 'evil-scroll-page-up
+ "[[" 'mu4e-conversation-previous-message
+ "]]" 'mu4e-conversation-next-message
+ "zv" 'mu4e-conversation-toggle-view
+ "za" 'mu4e-conversation-toggle-hide-cited
+ "q" 'mu4e-conversation-quit))
+
+(provide 'evil-collection-mu4e-conversation)
+;;; evil-collection-mu4e-conversation.el ends here