From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Amos Bird Newsgroups: gmane.emacs.devel Subject: Re: goto-address-at-point doesn't get the right url when there is a trailing ')' Date: Thu, 15 Jun 2017 21:49:47 +0800 Message-ID: <871sql4ays.fsf@gmail.com> References: <878tkv3rii.fsf@gmail.com> <877f0e5169.fsf@gmail.com> <8737b14o6r.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1497534637 26492 195.159.176.226 (15 Jun 2017 13:50:37 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 15 Jun 2017 13:50:37 +0000 (UTC) User-Agent: mu4e 0.9.19; emacs 25.2.2 Cc: Emacs developers , Yuri Khan To: Philipp Stephani Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jun 15 15:50:31 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dLVAM-0006XN-HL for ged-emacs-devel@m.gmane.org; Thu, 15 Jun 2017 15:50:30 +0200 Original-Received: from localhost ([::1]:54166 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dLVAR-0007MU-P5 for ged-emacs-devel@m.gmane.org; Thu, 15 Jun 2017 09:50:35 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55564) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dLV9p-0007M8-IZ for emacs-devel@gnu.org; Thu, 15 Jun 2017 09:49:58 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dLV9m-0007c7-HN for emacs-devel@gnu.org; Thu, 15 Jun 2017 09:49:57 -0400 Original-Received: from mail-pf0-x22b.google.com ([2607:f8b0:400e:c00::22b]:36763) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dLV9m-0007b8-Al for emacs-devel@gnu.org; Thu, 15 Jun 2017 09:49:54 -0400 Original-Received: by mail-pf0-x22b.google.com with SMTP id x63so7678928pff.3 for ; Thu, 15 Jun 2017 06:49:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version:content-transfer-encoding; bh=1jj+ovc7r3f76LCSW4rRAzkD3rVzz7JtXylHnVpzOLg=; b=Q3CoajBImM/JC2eM1FCx9YBB7qalv5SMmtoKJToWE6FXajCHiRx0Q6p7epxNA90FOt Pl7dixgF9GkzX1kNQQLdQ5irtJSBnxS8fGBEj/B5/GGGNTEtZwQ1TbT1GVJzGkrfqSPd B+OzF/NQrbmHnqFN6AdwhNt0jmQHB2O7zHwn+5h1v48PX1SEwL7QcQ+7ZeGxxWElBO+p 2JUoa1Pb9o2/WHrSe51lLZ3VJoTZoqkjxHVipog1JbTDmKIiqhtxDYSyDmIDLWQ/Yp6F AF44SQRrJgxzTmo3AowAqJvptPDrGlZRW/w2Tf+nS1Z/PkluHMa7cfoEjoXpHxMxLbeh 6X+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version:content-transfer-encoding; bh=1jj+ovc7r3f76LCSW4rRAzkD3rVzz7JtXylHnVpzOLg=; b=AQQinOT7C+aDSwqTXGG4VsyjtEbeidAbIoYGcqwyAMf/DwrilG98rYyxRu3MTvd0cM SSJ9unjyDjvPsp+aVBXUC87IJ9bYt6Ja65LuKMdRBXw18AHPFd3ftMumQHXRjXtkJfPo Tlj5NYfTDds28Z6RiFI5RLStyo8p7eKfoReAkSCkO3fOSD6lTbKd2/a7cDNdJf21WZqJ vADHCE/1a7rsxh12GU3XVqoz+QJkWyW68pK1hQImgt+IhAEuiNEs6m0f46WH9fVSVxLV t5jZZ023vz0b18f1itEkj9nou2m3Cs7MkMTac/qr71PO7STsvXv7ytBHiSZwwYKJOV1C nOHw== X-Gm-Message-State: AKS2vOyUn768Sm7R759+NI06uWnF+XXnuEsTnu3fT/aqE6xF5i4lBnLR QV7WAjhRaC6Izg== X-Received: by 10.99.178.75 with SMTP id t11mr5436331pgo.34.1497534591562; Thu, 15 Jun 2017 06:49:51 -0700 (PDT) Original-Received: from localhost ([168.235.77.108]) by smtp.gmail.com with ESMTPSA id 5sm472538pfe.60.2017.06.15.06.49.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 15 Jun 2017 06:49:50 -0700 (PDT) In-reply-to: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::22b X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.devel:215641 Archived-At: Thanks Philipp! I did some tests and it works quite well. regards, Amos Philipp Stephani writes: > The attached patch appears to do the right thing for me (but I haven't > tested it extensively). > > Amos Bird schrieb am Do., 15. Juni 2017 um 11:04 Uhr: > >> >> hmm, can you try doing it at a prog mode? say cc-mode or java-mode. >> >> Philipp Stephani writes: >> >> > Yuri Khan schrieb am Mi., 14. Juni 2017 um >> > 17:03 Uhr: >> > >> >> On Wed, Jun 14, 2017 at 5:11 PM, Amos Bird wrote: >> >> >> >> > When doing (goto-address-at-point) at parenthesis surrounded urls >> like >> >> this >> >> > (https://github.com/nikomatsakis/rayon/issues/231) in any prog mode >> (c, >> >> java, python ...) >> >> > >> >> > it will grab the trailing ')' thus ends up with opening a wrong url. >> >> >> >> > Could you tell me a workaround for this? >> >> >> >> Don’t do that, then? >> >> >> >> A closing parenthesis is a valid URL character. Any heuristic that >> >> fixes your problem will break legal, standard-conforming URLs, such as >> >> this: >> >> >> >> https://en.wikipedia.org/wiki/Dunnet_(video_game) >> >> >> > >> > The URL heuristic could match only paired parentheses. At least that's >> what >> > my mail app appears to be doing, as it correctly matches both URLs. >> >> > From 9c780b6ef06cacad989ea6175944af95c3973f14 Mon Sep 17 00:00:00 2001 > From: Philipp Stephani > Date: Thu, 15 Jun 2017 11:49:56 +0200 > Subject: [PATCH] Correctly detect URLs surrounded by parentheses in comments > > * lisp/thingatpt.el (thing-at-point--bounds-of-well-formed-url): > Make parentheses match work inside comments. > --- > lisp/thingatpt.el | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el > index 25e01df70e..7c3d73e52b 100644 > --- a/lisp/thingatpt.el > +++ b/lisp/thingatpt.el > @@ -380,7 +380,9 @@ thing-at-point--bounds-of-well-formed-url > (save-restriction > (narrow-to-region (1- url-beg) (min end (point-max))) > (setq paren-end (ignore-errors > - (scan-lists (1- url-beg) 1 0)))) > + ;; Make the scan work inside comments. > + (let ((parse-sexp-ignore-comments nil)) > + (scan-lists (1- url-beg) 1 0))))) > (not (blink-matching-check-mismatch (1- url-beg) paren-end)) > (setq end (1- paren-end))) > ;; Ensure PT is actually within BOUNDARY. Check the following