From 46476fc001408e71d87d59c73b8d663d11bc1deb Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Wed, 13 Jul 2022 23:35:16 +0300 Subject: [PATCH] mu4e: add mu4e-copy-thing-at-point Copy the thing (url or email) at point, similar to the feature in the pre-gnus view. Bind to 'c' in the message-view. --- mu4e/mu4e-helpers.el | 11 +++++++++++ mu4e/mu4e-view.el | 6 ++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/mu4e/mu4e-helpers.el b/mu4e/mu4e-helpers.el index 8c19a5a1..18c973d1 100644 --- a/mu4e/mu4e-helpers.el +++ b/mu4e/mu4e-helpers.el @@ -453,6 +453,17 @@ http://cr.yp.to/proto/maildir.html." ;;; Misc +(defun mu4e-copy-thing-at-point () + "Copy e-mail address or URL at point to the kill ring. +If there is not e-mail address at point, do nothing." + (interactive) + (let* ((thing (and (thing-at-point 'email) + (string-trim (thing-at-point 'email 'no-props) "<" ">"))) + (thing (or thing (thing-at-point 'url 'no-props)))) + (when thing + (kill-new thing) + (mu4e-message "Copied '%s' to kill-ring" thing)))) + (defun mu4e-display-size (size) "Get a human-friendly string representation of SIZE (in bytes)." (cond diff --git a/mu4e/mu4e-view.el b/mu4e/mu4e-view.el index 36a46a3a..3f047d49 100644 --- a/mu4e/mu4e-view.el +++ b/mu4e/mu4e-view.el @@ -949,9 +949,11 @@ This is useful for advising some Gnus-functionality that does not work in mu4e." ;; misc (define-key map "M" #'mu4e-view-massage) - (define-key map "w" 'visual-line-mode) + (define-key map "w" #'visual-line-mode) (define-key map "h" #'mu4e-view-toggle-html) - (define-key map (kbd "M-q") 'article-fill-long-lines) + (define-key map (kbd "M-q") #'article-fill-long-lines) + + (define-key map "c" #'mu4e-copy-thing-at-point) ;; next 3 only warn user when attempt in the message view (define-key map "u" #'mu4e-view-unmark)