From: Philipp Stephani <p.stephani2@gmail.com>
To: Amos Bird <amosbird@gmail.com>
Cc: Emacs developers <emacs-devel@gnu.org>,
Yuri Khan <yuri.v.khan@gmail.com>
Subject: Re: goto-address-at-point doesn't get the right url when there is a trailing ')'
Date: Thu, 15 Jun 2017 09:51:31 +0000 [thread overview]
Message-ID: <CAArVCkRa+NqjecDXgYpWx4i7qV5e+M0csf0CMfuai0gAqgpwkQ@mail.gmail.com> (raw)
In-Reply-To: <8737b14o6r.fsf@gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 1269 bytes --]
The attached patch appears to do the right thing for me (but I haven'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
> > 17:03 Uhr:
> >
> >> On Wed, Jun 14, 2017 at 5:11 PM, Amos Bird <amosbird@gmail.com> 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.
>
>
[-- Attachment #1.2: Type: text/html, Size: 2115 bytes --]
[-- Attachment #2: 0001-Correctly-detect-URLs-surrounded-by-parentheses-in-com.txt --]
[-- Type: text/plain, Size: 1178 bytes --]
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 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
--
2.13.1
next prev parent reply other threads:[~2017-06-15 9:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <878tkv3rii.fsf@gmail.com>
2017-06-14 10:11 ` goto-address-at-point doesn't get the right url when there is a trailing ')' Amos Bird
2017-06-14 15:01 ` Yuri Khan
2017-06-14 15:05 ` Amos Bird
2017-06-15 9:01 ` Philipp Stephani
2017-06-15 9:04 ` Amos Bird
2017-06-15 9:51 ` Philipp Stephani [this message]
2017-06-15 13:49 ` Amos Bird
2017-06-16 16:27 ` Philipp Stephani
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAArVCkRa+NqjecDXgYpWx4i7qV5e+M0csf0CMfuai0gAqgpwkQ@mail.gmail.com \
--to=p.stephani2@gmail.com \
--cc=amosbird@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=yuri.v.khan@gmail.com \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).