diff options
-rw-r--r-- | lisp/km-mail.el | 22 |
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)))) |