discussion and development of piem
 help / color / mirror / code / Atom feed
From: Kyle Meyer <kyle@kyleam.com>
To: piem@inbox.kyleam.com
Cc: Xinglu Chen <public@yoctocell.xyz>
Subject: [PATCH 4/5] piem-copy-mid-url: Allow overriding browse-url-browser-function
Date: Sun,  7 Feb 2021 02:57:37 -0500	[thread overview]
Message-ID: <20210207075738.8752-5-kyle@kyleam.com> (raw)
In-Reply-To: <20210207075738.8752-1-kyle@kyleam.com>

I don't use EWW as my default browser for browse-url, but, for
public-inbox HTTP access, I primarily use EWW.  Add an option that
makes it easier to do so without adding lots of regular expressions to
browse-url-browser-function.
---
 piem.el | 31 +++++++++++++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/piem.el b/piem.el
index 5a646c5..6424498 100644
--- a/piem.el
+++ b/piem.el
@@ -192,6 +192,29 @@ (defcustom piem-after-mail-injection-functions nil
 `piem-inject-thread-into-maildir'."
   :type 'hook)
 
+(defcustom piem-browse-url-browser-function nil
+  "Overriding value for `browse-url-browser-function'.
+
+public-inbox's HTTP interface is well suited for browsers like
+w3m and EWW, allowing you to stay in Emacs rather than launch an
+external browser.  However, assuming you have `browse-url'
+configured to usually go through an external browser, sending
+public-inbox URLs through, say, EWW would require you to
+configure `browse-url-browser-function' with a regular expression
+for each inbox URL that you want to be handled by
+`eww-browse-url'.
+
+Instead, you can simply set this option to `eww-browse-url' (or
+anything else `browse-url-browser-function' accepts), and piem
+will use it when calling `browse-url'.
+
+When this option is nil, piem calls `browse-url' without
+overriding the value of `browse-url-browser-function'."
+  :type (append
+         '(choice
+           (const :tag "Don't override `browse-url-browser-function'" nil))
+         (cdr (get 'browse-url-browser-function 'custom-type))))
+
 \f
 ;;;; Subprocess handling
 
@@ -471,7 +494,8 @@ (defun piem-mid-url (mid &optional 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."
+afterwards.  If `piem-browse-url-browser-function' is non-nil, it
+is used as the value of `browse-url-browser-function'."
   (interactive "P")
   (let ((url (piem-mid-url
               (or (piem-mid)
@@ -480,7 +504,10 @@ (defun piem-copy-mid-url (&optional browse)
     (prog1
         (kill-new (message "%s" url))
       (when browse
-        (browse-url url)))))
+        (let ((browse-url-browser-function
+               (or piem-browse-url-browser-function
+                   browse-url-browser-function)))
+          (browse-url url))))))
 
 \f
 ;;;; Download helpers
-- 
2.30.0


  parent reply	other threads:[~2021-02-07  7:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-07  7:57 [PATCH 0/5] New command for copying public-inbox URLs Kyle Meyer
2021-02-07  7:57 ` [PATCH 1/5] piem: Add helper to construct message ID link Kyle Meyer
2021-02-07  7:57 ` [PATCH 2/5] piem-dispatch: Add command for copying public-inbox URLs Kyle Meyer
2021-02-07  7:57 ` [PATCH 3/5] piem-copy-mid-url: Add support for browsing url Kyle Meyer
2021-02-07  7:57 ` Kyle Meyer [this message]
2021-02-07  7:57 ` [PATCH 5/5] manual: Add section on "copy public-inbox link" functionality Kyle Meyer
2021-02-07 12:38 ` [PATCH 0/5] New command for copying public-inbox URLs Xinglu Chen
2021-02-07 16:57   ` Kyle Meyer
2021-02-07 17:35     ` Kyle Meyer
2021-02-07 20:25       ` Xinglu Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://git.kyleam.com/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210207075738.8752-5-kyle@kyleam.com \
    --to=kyle@kyleam.com \
    --cc=piem@inbox.kyleam.com \
    --cc=public@yoctocell.xyz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.kyleam.com/piem/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).