emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/xkcd 2923195a57 53/82: Add customization option for handli


From: ELPA Syncer
Subject: [nongnu] elpa/xkcd 2923195a57 53/82: Add customization option for handling links.
Date: Mon, 12 Dec 2022 21:59:53 -0500 (EST)

branch: elpa/xkcd
commit 2923195a576b9e36f36d895a4e2f0e34fa2af7dd
Author: Vibhav Pant <vibhavp@gmail.com>
Commit: Vibhav Pant <vibhavp@gmail.com>

    Add customization option for handling links.
---
 xkcd.el | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/xkcd.el b/xkcd.el
index b3bea57897..fae45d0e03 100644
--- a/xkcd.el
+++ b/xkcd.el
@@ -66,6 +66,11 @@ Should preferably be located in `xkcd-cache-dir'."
   :group 'xkcd
   :type 'file)
 
+(defcustom xkcd-handle-links t
+  "Handle xkcd links by opening them with xkcd-get"
+  :group 'xkcd
+  :type 'boolean)
+
 (defun xkcd-get-json (url &optional num)
   "Fetch the Json coming from URL.
 If the file NUM.json exists, use it instead.
@@ -192,12 +197,14 @@ If the image is a gif, animate it."
         (number (substring string 0 (string-match "/" string))))
     (xkcd-get (string-to-number number))))
 
-(setq browse-url-browser-function (lambda (url etc) (if 
-                                                   (string-match
-                                                    "xkcd.com/[0-9]+"
-                                                    "http://xkcd.com/123/";)
-                                                   (get-xkcd-from-url url)
-                                                   
'browse-url-default-browser)))
+(setq browse-url-browser-function (if xkcd-handle-link
+                                     (lambda (url etc)
+                                       (if (string-match "xkcd.com/[0-9]+"
+                                            "http://xkcd.com/123/";)
+                                           (get-xkcd-from-url url)
+                                         
+                                         'browse-url-default-browser))
+                                   'browse-url-default-browser))
 
 (defun xkcd-get-latest ()
   "Get the latest xkcd."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]