[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Fix browse-url not working when browse-url-browser-function
From: |
vibhavp |
Subject: |
Re: [PATCH] Fix browse-url not working when browse-url-browser-function is a list (regexp . function) pairs |
Date: |
Sat, 25 Apr 2015 22:40:14 +0530 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
Eli Zaretskii <address@hidden> writes:
> But the way browse-url-browser-function is documented, it should be a
> list of conses, not a list of lists. With your change, if
> browse-url-browser-function is an alist, like the doc string implies,
> the function will now fail. So other users out there might suffer.
I phrased that wrong. Making browse-url-browse-function a list of lists
will not make sense to being with. The way browse-url works is by
iterating thorough every (REGEXP . FUNCTION) pair in
browse-url-browse-function, and applying string-match to the REGEXP
(which is the car of the pair) to the url. If the url matches the
REGEXP, browse-url opens the URL with it's associated function (the cdr
of the pair).
However (for some reason), (car bf) returns (browser-function) instead
of browse-function, which can be demonstrated with this piece of code:
(defun abc ()
(dolist (bf '(("i.imgur.com" browse-url-emacs)
("youtube.com" browse-url-firefox)
("." browse-url-chromium)))
(print (cdr bf))))
The output of this is:
(browse-url-emacs)
(browse-url-firefox)
(browse-url-chromium)
nil
This is not what we want, because applying (browse-url-emacs) to the URL
results in an "invalid function" error. If the "car" is replaced with a
"cadr", this is the output:
"browse-url-emacs"
"browse-url-youtube"
"browse-url-chromium"
nil
This is the desired outcome. So, I'm not sure if this change requires a
documentation change, because it is merely fixing a bug with how
browse-url function handles the variable.
Thanks,
Vibhav
--
Vibhav Pant
address@hidden