From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: vibhavp@gmail.com Newsgroups: gmane.emacs.devel 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 Message-ID: <878udhwgwo.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1429898123 22414 80.91.229.3 (24 Apr 2015 17:55:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 24 Apr 2015 17:55:23 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Apr 24 19:55:14 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Ylhof-0007C9-8M for ged-emacs-devel@m.gmane.org; Fri, 24 Apr 2015 19:55:05 +0200 Original-Received: from localhost ([::1]:45862 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ylhoe-0008Ub-Kx for ged-emacs-devel@m.gmane.org; Fri, 24 Apr 2015 13:55:04 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45226) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ylhoa-0008UL-Ry for emacs-devel@gnu.org; Fri, 24 Apr 2015 13:55:01 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YlhoX-0002HV-GA for emacs-devel@gnu.org; Fri, 24 Apr 2015 13:55:00 -0400 Original-Received: from mail-wi0-x234.google.com ([2a00:1450:400c:c05::234]:32822) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YlhoX-0002HI-9b for emacs-devel@gnu.org; Fri, 24 Apr 2015 13:54:57 -0400 Original-Received: by wiax7 with SMTP id x7so40254320wia.0 for ; Fri, 24 Apr 2015 10:54:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:mime-version:content-type; bh=3Zj7D1UUNGnERoXXe2dIT69xx3rL/A3reB0OwpMhDiQ=; b=SaRz1FVYnXUbQZZT5R6ndlq2Xy3sVelRX5TdbM4gA9l2qYNMebXSMM414rrwWktPnP Vwt0oMwSlKN4z1sa2TWeVXT3a6tKvPXz7OaUINgEuAS0leuQ5oC8MjBMo9pv/bfDSS43 YDjbxN/dsURjl5FB0cQgq5U2SF4c0uXm4vAXaQPo3F4gQ8XrBRjIWEonjJ4kCQh1SjQ7 c4ustT3IoUx4hQKvta8E7MxFbNVT+MwrdvclUr7iTuPmcsocNDXp84GWVI1yhYFJP7RT mcBKc2DE5CggZuXzy7FYM1WWnV+j1BfdQUF9jh/MzUjIPoj0N3gc8z9lcDlAZcE2QBR5 dB+w== X-Received: by 10.194.86.101 with SMTP id o5mr18330488wjz.8.1429898096606; Fri, 24 Apr 2015 10:54:56 -0700 (PDT) Original-Received: from lenovog410 ([59.89.22.145]) by mx.google.com with ESMTPSA id gi17sm17831224wjc.8.2015.04.24.10.54.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Apr 2015 10:54:54 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::234 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:185857 Archived-At: --=-=-= Content-Type: text/plain 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. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=browse-url-fix.patch 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)) --=-=-= Content-Type: text/plain Thanks, Vibhav -- Vibhav Pant vibhavp@gmail.com --=-=-=--