summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2020-04-03 10:38:02 -0400
committerKyle Meyer <kyle@kyleam.com>2020-09-01 22:57:19 -0400
commite264d496ee390fb527aadace1e4ad66b166a3668 (patch)
treeacfd5aca9f87fda00aa6981426cd80ddf477437e /lisp
parent1baf95772d553534837a6d72e20a62a7cf903c72 (diff)
downloademacs.d-e264d496ee390fb527aadace1e4ad66b166a3668.tar.gz
km/notmuch-show-at-point: Support region selection
Diffstat (limited to 'lisp')
-rw-r--r--lisp/km-mail.el22
1 files changed, 13 insertions, 9 deletions
diff --git a/lisp/km-mail.el b/lisp/km-mail.el
index 5b9b26d..2effb1e 100644
--- a/lisp/km-mail.el
+++ b/lisp/km-mail.el
@@ -95,15 +95,19 @@
(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 (zero-or-one "<")
- (group (zero-or-one (or "id:" "thread:")))
- (group (one-or-more (any "-" "_" "." "@" "/" alnum)))))
- (concat (let ((prefix (match-string 1)))
- (if (string= prefix "") "id:" prefix))
- (match-string-no-properties 2))))))
+ (let ((id (if (use-region-p)
+ (concat "id:"
+ (buffer-substring-no-properties
+ (region-beginning) (region-end)))
+ (save-excursion
+ (skip-syntax-backward "^\\s-")
+ (and (looking-at
+ (rx (zero-or-one "<")
+ (group (zero-or-one (or "id:" "thread:")))
+ (group (one-or-more (any "-" "_" "." "@" "/" alnum)))))
+ (concat (let ((prefix (match-string 1)))
+ (if (string= prefix "") "id:" prefix))
+ (match-string-no-properties 2)))))))
(if id
(notmuch-show id)
(call-interactively #'notmuch-show))))