unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] Fix browse-url not working when browse-url-browser-function is a list (regexp . function) pairs
@ 2015-04-24 17:54 vibhavp
  2015-04-25 16:14 ` vibhavp
  0 siblings, 1 reply; 6+ messages in thread
From: vibhavp @ 2015-04-24 17:54 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 890 bytes --]

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.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: browse-url-fix.patch --]
[-- Type: text/x-diff, Size: 469 bytes --]

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))

[-- Attachment #3: Type: text/plain, Size: 50 bytes --]


Thanks,
Vibhav
-- 
Vibhav Pant
vibhavp@gmail.com

^ permalink raw reply related	[flat|nested] 6+ messages in thread
* Re: [PATCH] Fix browse-url not working when browse-url-browser-function is a list (regexp . function) pairs
@ 2015-04-25 17:47 vibhavp
  0 siblings, 0 replies; 6+ messages in thread
From: vibhavp @ 2015-04-25 17:47 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Ah, I was confused between conses and lists. Sorry for all the confusion.
-- 
Vibhav Pant
vibhavp@gmail.com



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-04-25 17:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-24 17:54 [PATCH] Fix browse-url not working when browse-url-browser-function is a list (regexp . function) pairs vibhavp
2015-04-25 16:14 ` vibhavp
2015-04-25 16:28   ` Eli Zaretskii
2015-04-25 17:10     ` vibhavp
2015-04-25 17:33       ` Eli Zaretskii
  -- strict thread matches above, loose matches on Subject: below --
2015-04-25 17:47 vibhavp

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).