[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Fix browse-url not working when browse-url-browser-function is a
From: |
vibhavp |
Subject: |
[PATCH] Fix browse-url not working when browse-url-browser-function is a list (regexp . function) pairs |
Date: |
Fri, 24 Apr 2015 23:24:47 +0530 |
If browse-url-browser-function is defined as a list of pairs
(REGEXP . FUNCTION), like:
(setq browse-url-browser-function '(("i\.imgur\.com" browse-url-emacs)
("." browse-url-chromium)))
browse-url (with an "i.imgur.com" url) will print an error saying that
"(invalid-function (browse-url-chromium))". This is probably because of
how browse-url handles such pairs:
;; The `function' can be an alist; look down it for first match
;; and apply the function (which might be a lambda).
(catch 'done
(dolist (bf function)
(when (string-match (car bf) url)
(apply (cdr bf) url args)
^^^^^^ (cdr bf) returns (browse-url-emacs) instead of
browse-url-emacs
(throw 'done t)))
This can be easily fixed by replacing "(cdr bf)" with "(cadr bf)". I
have attached a patch which does the same. If it looks good, I'll push
it to master.
diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el
index 3f8cb84..fbf2b46 100644
--- a/lisp/net/browse-url.el
+++ b/lisp/net/browse-url.el
@@ -792,7 +792,7 @@ The default is to pass `browse-url-new-window-flag'."
(catch 'done
(dolist (bf function)
(when (string-match (car bf) url)
- (apply (cdr bf) url args)
+ (apply (cadr bf) url args)
(throw 'done t)))
(error "No browse-url-browser-function matching URL %s"
url))
Thanks,
Vibhav
--
Vibhav Pant
address@hidden
- [PATCH] Fix browse-url not working when browse-url-browser-function is a list (regexp . function) pairs,
vibhavp <=