summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2017-03-28 23:51:51 -0400
committerKyle Meyer <kyle@kyleam.com>2017-03-28 23:51:51 -0400
commit23a6abef8c26704cce184477d2503b3f61148d68 (patch)
treeaa252e44dbaafffcdc499f3a788f93eaefc1b83b
parent585b59c4839896e9d513604b7f1ef315e40ebfec (diff)
downloademacs.d-23a6abef8c26704cce184477d2503b3f61148d68.tar.gz
Add notmuch-show-at-point command
-rw-r--r--init.el6
-rw-r--r--lisp/km-mail.el15
2 files changed, 19 insertions, 2 deletions
diff --git a/init.el b/init.el
index 4b4f8e3..7f9b101 100644
--- a/init.el
+++ b/init.el
@@ -2090,6 +2090,8 @@
(use-package km-mail
:defer t
:after notmuch
+ :init
+ (define-key km/mail-map "." #'km/notmuch-show-at-point)
:config
(define-key notmuch-search-mode-map "R" #'km/notmuch-archive-all)
(define-key notmuch-show-part-map "|"
@@ -2280,9 +2282,9 @@
(let ((server (daemonp)))
(cond
((string= server "default")
- ;; Remove all mail map bindings except notmuch.
- (global-set-key (kbd "C-x m") nil)
+ ;; Remove all mail map bindings except notmuch-related ones.
(global-set-key (kbd "C-x m n") #'notmuch)
+ (global-set-key (kbd "C-x m .") #'km/notmuch-show-at-point)
(after 'km-python
(add-hook 'kill-emacs-hook #'km/pydoc-save-names-file))
(setq save-abbrevs 'silently
diff --git a/lisp/km-mail.el b/lisp/km-mail.el
index 345d2bb..b25934c 100644
--- a/lisp/km-mail.el
+++ b/lisp/km-mail.el
@@ -57,6 +57,21 @@
(mark-whole-buffer)
(call-interactively #'notmuch-search-archive-thread))
+;;;###autoload
+(defun km/notmuch-show-at-point ()
+ "Call `notmuch-show' with message or thread ID at point."
+ (interactive)
+ (let ((id (save-excursion
+ (skip-syntax-backward "^\\s-")
+ (and (looking-at
+ (rx (group (zero-or-one (or "id:" "thread:")))
+ (one-or-more (any "-" "_" "." "@" "/" alnum))))
+ (concat (and (string= (match-string 1) "") "id:")
+ (match-string-no-properties 0))))))
+ (if id
+ (notmuch-show id)
+ (call-interactively #'notmuch-show))))
+
;;; Mail sync