From 59ab05cef5762bbb09868980014571385e9e3183 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sun, 7 Feb 2021 02:57:36 -0500 Subject: piem-copy-mid-url: Add support for browsing url I find the notmuch-show-stash-mlarchive-link-and-go command useful. It's like notmuch-show-stash-mlarchive-link but calls browse-url on the copied URL. Make piem-copy-mid-url do the same when given a prefix argument. Message-Id: <20210207075738.8752-4-kyle@kyleam.com> --- piem.el | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/piem.el b/piem.el index 0ed288a..5a646c5 100644 --- a/piem.el +++ b/piem.el @@ -37,6 +37,7 @@ ;;; Code: +(require 'browse-url) (require 'cl-lib) (require 'mail-extr) (require 'message) @@ -467,15 +468,19 @@ INBOX is nil, use the inbox returned by `piem-inbox'." (or inbox "current buffer")))) (piem-escape-mid mid))) -(defun piem-copy-mid-url () - "Copy public-inbox URL for the current buffer's message." - (interactive) - (kill-new - (message "%s" - (piem-mid-url - (or (piem-mid) - (user-error "No message ID found for the current buffer")) - (piem-inbox))))) +(defun piem-copy-mid-url (&optional browse) + "Copy public-inbox URL for the current buffer's message. +With prefix argument BROWSE, call `browse-url' on the URL +afterwards." + (interactive "P") + (let ((url (piem-mid-url + (or (piem-mid) + (user-error "No message ID found for the current buffer")) + (piem-inbox)))) + (prog1 + (kill-new (message "%s" url)) + (when browse + (browse-url url))))) ;;;; Download helpers -- cgit v1.2.3