From mboxrd@z Thu Jan 1 00:00:00 1970
Path: news.gmane.org!.POSTED!not-for-mail
From: Philipp Stephani
Newsgroups: gmane.emacs.devel
Subject: Re: goto-address-at-point doesn't get the right url when there is a
trailing ')'
Date: Fri, 16 Jun 2017 16:27:28 +0000
Message-ID:
References: <878tkv3rii.fsf@gmail.com> <877f0e5169.fsf@gmail.com>
<8737b14o6r.fsf@gmail.com>
<871sql4ays.fsf@gmail.com>
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="001a11c14faa8b04c305521643f3"
X-Trace: blaine.gmane.org 1497630515 16181 195.159.176.226 (16 Jun 2017 16:28:35 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Fri, 16 Jun 2017 16:28:35 +0000 (UTC)
Cc: Emacs developers , Yuri Khan
To: Amos Bird
Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jun 16 18:28:30 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 1dLu6n-0003p7-8l
for ged-emacs-devel@m.gmane.org; Fri, 16 Jun 2017 18:28:29 +0200
Original-Received: from localhost ([::1]:59842 helo=lists.gnu.org)
by lists.gnu.org with esmtp (Exim 4.71)
(envelope-from )
id 1dLu6s-0008Ij-Dj
for ged-emacs-devel@m.gmane.org; Fri, 16 Jun 2017 12:28:34 -0400
Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33175)
by lists.gnu.org with esmtp (Exim 4.71)
(envelope-from ) id 1dLu64-00088u-45
for emacs-devel@gnu.org; Fri, 16 Jun 2017 12:27:45 -0400
Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
(envelope-from ) id 1dLu62-00082K-LE
for emacs-devel@gnu.org; Fri, 16 Jun 2017 12:27:44 -0400
Original-Received: from mail-oi0-x233.google.com ([2607:f8b0:4003:c06::233]:34285)
by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
(Exim 4.71) (envelope-from )
id 1dLu62-00080t-EE
for emacs-devel@gnu.org; Fri, 16 Jun 2017 12:27:42 -0400
Original-Received: by mail-oi0-x233.google.com with SMTP id b6so26934740oia.1
for ; Fri, 16 Jun 2017 09:27:40 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to
:cc; bh=zT3ODRtvwzAdkv56XlKINhBnHHlkJk5cFZEy7VJXTTk=;
b=iW0MBYNvfHgovvpyK2uaim2KQ1sg27YZSXHCAKkiWLWepbFuemOEBknRTJxG2gGX5G
JZbrqrsYayA1BqnaB0hJnLIyN7mZpHin4tgJ+L33Mmne3Qw7kMmgIJWI1iTVtYX2wrvl
QJ27P7sZRVTP8l2U97v+M4pCfZ9HPLj0n3g69tMDl3uUieP08gr476ekx4+7r+udfjjv
QakBjOtcJqostxw9puiJaFUHb0YQKbQLT2bqoMU4klr+i7QONNJ55RYij71h2WhTqVwE
i7kycXS+7P7yFV2LQR/xc1wJ9t5N76IyMwmZ2056ntRmjQT28D6PlOKjv3EbVh2znccr
iVbg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to:cc;
bh=zT3ODRtvwzAdkv56XlKINhBnHHlkJk5cFZEy7VJXTTk=;
b=Yvqx2cVCHfNuv+6x+vgbvEcAOJoloTBTK86VOHQ693Rr2NIOFUbMQf5aIpjjjsmYxm
IonEgo1P0nMuoeSEF+RxBTmlDFxuGhYg+IhPbrTBqkqU1AJiLNAKBdRbb4RzXqDVx1An
N1LrqBquD+LVrA6/mNxeKCPlz2f3eAqxx7fUaM+f2PnZEsjQTpwv2/uRyjhqPQ4Fm+b4
8kRFpKbbNHhtmx606pCSGtDSGA9X9jZmijDRilLmd03j0L+7V82nZixASxh9+Z+zSo+b
4WkVmCD6WM3CuQyJAfX5rQFUVJSpXbu9TkRbNB8spGCW3MKrExuEQGAdbOXZHEY6viQO
mKLw==
X-Gm-Message-State: AKS2vOztYTYEpobjNaNUa3ZQvS77BY3JI4tE9uwto/efoG8lmOlmUtpR
KT8VAifqPzxOhLAHXZcKKlDyRLqdcQ==
X-Received: by 10.202.117.8 with SMTP id q8mr5448497oic.191.1497630459490;
Fri, 16 Jun 2017 09:27:39 -0700 (PDT)
In-Reply-To: <871sql4ays.fsf@gmail.com>
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
recognized.
X-Received-From: 2607:f8b0:4003:c06::233
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:215674
Archived-At:
--001a11c14faa8b04c305521643f3
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
OK, I've pushed this as 3b6e01cccf89ba0f3485751125f43463bc429345 to master
and added a unit test.
Amos Bird schrieb am Do., 15. Juni 2017 um 15:49 Uhr:
>
> 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 url=
s
> >> 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=E2=80=99t 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
>
>
--001a11c14faa8b04c305521643f3
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
OK, I've pushed this as=C2=A03b6e01cccf89ba0f348575112=
5f43463bc429345 to master and added a unit test.
Thanks Philipp! I did some tests and it works quite well.
regards,
Amos
Philipp Stephani <p.stephani2@gmail.com> writes:
> The attached patch appears to do the right thing for me (but I haven=
39;t
> tested it extensively).
>
> Amos Bird <=
amosbird@gmail.com> 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 <p.stephani2@gmail.com> writes:
>>
>> > Yuri Khan <yuri.v.khan@gmail.com> schrieb am Mi., 14. Juni 2017 um<=
br>
>> > 17:03 Uhr:
>> >
>> >> On Wed, Jun 14, 2017 at 5:11 PM, Amos Bird <amosbird@gmail.com> wr=
ote:
>> >>
>> >> > When doing=C2=A0 (goto-address-at-point) at parenthe=
sis surrounded urls
>> like
>> >> this
>> >> > (https://github.com/nikomatsa=
kis/rayon/issues/231) in any prog mode
>> (c,
>> >> java, python ...)
>> >> >
>> >> > it will grab the trailing ')' thus ends up w=
ith opening a wrong url.
>> >>
>> >> > Could you tell me a workaround for this?
>> >>
>> >> Don=E2=80=99t do that, then?
>> >>
>> >> A closing parenthesis is a valid URL character. Any heuri=
stic that
>> >> fixes your problem will break legal, standard-conforming =
URLs, such as
>> >> this:
>> >>
>> >>=C2=A0 =C2=A0 =C2=A0https://en.wik=
ipedia.org/wiki/Dunnet_(video_game)
>> >>
>> >
>> > The URL heuristic could match only paired parentheses. At lea=
st 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 <phst@google.com>
> Date: Thu, 15 Jun 2017 11:49:56 +0200
> Subject: [PATCH] Correctly detect URLs surrounded by parentheses in co=
mments
>
> * lisp/thingatpt.el (thing-at-point--bounds-of-well-formed-url):
> Make parentheses match work inside comments.
> ---
>=C2=A0 lisp/thingatpt.el | 4 +++-
>=C2=A0 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
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (save-restriction
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (narrow-to-region (1- =
url-beg) (min end (point-max)))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq paren-end (ignor=
e-errors
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (scan-lists (1- url-beg) 1 0))))
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; Make the scan work insi=
de comments.
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(let ((parse-sexp-ignore-c=
omments nil))
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(scan-lists (1- url=
-beg) 1 0)))))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (not (blink-matching-check-mi=
smatch (1- url-beg) paren-end))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq end (1- paren-end)))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0;; Ensure PT is actually within BOUNDARY. Ch=
eck the following
--001a11c14faa8b04c305521643f3--