diff options
author | Kyle Meyer <kyle@kyleam.com> | 2020-04-03 10:38:02 -0400 |
---|---|---|
committer | Kyle Meyer <kyle@kyleam.com> | 2020-09-01 22:57:19 -0400 |
commit | e264d496ee390fb527aadace1e4ad66b166a3668 (patch) | |
tree | acfd5aca9f87fda00aa6981426cd80ddf477437e | |
parent | 1baf95772d553534837a6d72e20a62a7cf903c72 (diff) | |
download | emacs.d-e264d496ee390fb527aadace1e4ad66b166a3668.tar.gz |
km/notmuch-show-at-point: Support region selection
-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)))) |