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: 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 Message-ID: <87d22s16dl.fsf@gmail.com> References: <878udhwgwo.fsf@gmail.com> <87h9s418yi.fsf@gmail.com> <83egn8xjcw.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1429981851 6644 80.91.229.3 (25 Apr 2015 17:10:51 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 25 Apr 2015 17:10:51 +0000 (UTC) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Apr 25 19:10:40 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 1Ym3bD-0001UD-Sn for ged-emacs-devel@m.gmane.org; Sat, 25 Apr 2015 19:10:40 +0200 Original-Received: from localhost ([::1]:48961 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ym3bD-0002zi-55 for ged-emacs-devel@m.gmane.org; Sat, 25 Apr 2015 13:10:39 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52243) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ym3b7-0002yd-Ni for emacs-devel@gnu.org; Sat, 25 Apr 2015 13:10:34 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ym3b2-0004Vn-HX for emacs-devel@gnu.org; Sat, 25 Apr 2015 13:10:33 -0400 Original-Received: from mail-pa0-x242.google.com ([2607:f8b0:400e:c03::242]:32932) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ym3b2-0004VC-2e; Sat, 25 Apr 2015 13:10:28 -0400 Original-Received: by pablf10 with SMTP id lf10so24643901pab.0; Sat, 25 Apr 2015 10:10:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=4p0uValCprkp8SoIGrdCc3os6QW6lZRobi71+xoQ7fI=; b=f4nVyb8t9mDTO1eHmoDHDBKs/3EWuaRD3tPoubdsH5X9Wjc7gzscfNttogGBBYpiBg 6XIBCTHRQPG7N2tVMxP1HfnOdssx83UhV2lGrq7/PRsZH05b16cj04gJS9t3S85McDtc cKKpmNLHcxFOcE1b1gsrQkSyhpWVn7JYhIkLNFtVd0s79C99teztCWmwSEP5M8bDkkCY BkBF1LShNDAdZwTQxo4Vah47r1kURp7BMp1osU4B8pnrp7eMiy1SRD6Uob7Jy4CZouVp cFJ9B1mu7IKDcLwkrkWOZbvSnXGKKI6Jr8EMrrGOCuSyMunAC07ZYmBQAiKkZSZH7xGS pdug== X-Received: by 10.68.93.68 with SMTP id cs4mr7566118pbb.139.1429981827205; Sat, 25 Apr 2015 10:10:27 -0700 (PDT) Original-Received: from lenovog410 ([117.201.81.247]) by mx.google.com with ESMTPSA id sf6sm14442916pbb.82.2015.04.25.10.10.25 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Apr 2015 10:10:26 -0700 (PDT) In-Reply-To: <83egn8xjcw.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 25 Apr 2015 19:28:47 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c03::242 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:185880 Archived-At: Eli Zaretskii 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 vibhavp@gmail.com