all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: vibhavp@gmail.com
To: emacs-devel@gnu.org
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	[thread overview]
Message-ID: <878udhwgwo.fsf@gmail.com> (raw)

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

             reply	other threads:[~2015-04-24 17:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-24 17:54 vibhavp [this message]
2015-04-25 16:14 ` [PATCH] Fix browse-url not working when browse-url-browser-function is a list (regexp . function) pairs 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878udhwgwo.fsf@gmail.com \
    --to=vibhavp@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.