From e264d496ee390fb527aadace1e4ad66b166a3668 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Fri, 3 Apr 2020 10:38:02 -0400 Subject: km/notmuch-show-at-point: Support region selection --- lisp/km-mail.el | 22 +++++++++++++--------- 1 file 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)))) -- cgit v1.2.3