From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:863f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms12 with LMTPS id oJsLHYCdH2BlXwAAsNZ9tg (envelope-from ); Sun, 07 Feb 2021 07:57:52 +0000 Received: from out1.migadu.com ([2001:41d0:2:863f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id EPV4CX6dH2CjRQAAbx9fmQ (envelope-from ); Sun, 07 Feb 2021 07:57:50 +0000 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kyleam.com; s=key1; t=1612684670; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VG5VuBR0EyjaKyUWpF0KOuej+UWWRvVKEsoUP6cov7E=; b=b0pvWeFSO1DrISUejM19guJxGq4dFTI5D+U7bSmg2+Ewa8sAu3TilLbECLjcKkSTBm8uCD rculJHbOFW3/hqkBrpRAfpL5IqAY1OqZaRCSJX+tKMKZjdeq/1buZdMsNXmNyISZNXPnH/ zpkvD+JBjs224lYvwfipjBnpn7lxGFcvGbOsHvgXHV5+iRLeprm9PAM/DkWrSwlHd8wXu9 GA//CiXlwopy2GYK9Xfy4ojfIeU+l6TZR4OBtTYzQvc4U8glcbpb3hYKT1T2pT0BtbkwSj lnnKFLFeso4C5f4qqlaZCL4llABE++Cyij3Dr+um8Ho27NUZNlGYswm0opVc3g== From: Kyle Meyer To: piem@inbox.kyleam.com Cc: Xinglu Chen Subject: [PATCH 4/5] piem-copy-mid-url: Allow overriding browse-url-browser-function Date: Sun, 7 Feb 2021 02:57:37 -0500 Message-Id: <20210207075738.8752-5-kyle@kyleam.com> In-Reply-To: <20210207075738.8752-1-kyle@kyleam.com> References: <20210207075738.8752-1-kyle@kyleam.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: kyle@kyleam.com X-TUID: w+gMEsZkpPSd 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)))) + ;;;; 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)))))) ;;;; Download helpers -- 2.30.0