* goto-address-at-point doesn't get the right url when there is a trailing ')' [not found] <878tkv3rii.fsf@gmail.com> @ 2017-06-14 10:11 ` Amos Bird 2017-06-14 15:01 ` Yuri Khan 0 siblings, 1 reply; 8+ messages in thread From: Amos Bird @ 2017-06-14 10:11 UTC (permalink / raw) To: emacs-devel Deer emacs devs, 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. it works fine in text-mode. Could you tell me a workaround for this? Thank you! Amos ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: goto-address-at-point doesn't get the right url when there is a trailing ')' 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 0 siblings, 2 replies; 8+ messages in thread From: Yuri Khan @ 2017-06-14 15:01 UTC (permalink / raw) To: Amos Bird; +Cc: Emacs developers 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) If you want to enclose a URL in parentheses, put a pair of angle brackets <> around it first: (<https://github.com/nikomatsakis/rayon/issues/231>) Angle brackets are not valid URL characters and are expicitly recommended as delimiters around URLs by RFC 2396 § 2.4.3 and RFC 3986 Appendix C. Also, it is a Markdown construct for URLs displayed as-is. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: goto-address-at-point doesn't get the right url when there is a trailing ')' 2017-06-14 15:01 ` Yuri Khan @ 2017-06-14 15:05 ` Amos Bird 2017-06-15 9:01 ` Philipp Stephani 1 sibling, 0 replies; 8+ messages in thread From: Amos Bird @ 2017-06-14 15:05 UTC (permalink / raw) To: Yuri Khan; +Cc: Emacs developers Thanks! will do. Yuri Khan <yuri.v.khan@gmail.com> writes: > 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) > > If you want to enclose a URL in parentheses, put a pair of angle > brackets <> around it first: > > (<https://github.com/nikomatsakis/rayon/issues/231>) > > Angle brackets are not valid URL characters and are expicitly > recommended as delimiters around URLs by RFC 2396 § 2.4.3 and RFC 3986 > Appendix C. Also, it is a Markdown construct for URLs displayed as-is. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: goto-address-at-point doesn't get the right url when there is a trailing ')' 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 1 sibling, 1 reply; 8+ messages in thread From: Philipp Stephani @ 2017-06-15 9:01 UTC (permalink / raw) To: Yuri Khan, Amos Bird; +Cc: Emacs developers [-- Attachment #1: Type: text/plain, Size: 866 bytes --] 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 #2: Type: text/html, Size: 1447 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: goto-address-at-point doesn't get the right url when there is a trailing ')' 2017-06-15 9:01 ` Philipp Stephani @ 2017-06-15 9:04 ` Amos Bird 2017-06-15 9:51 ` Philipp Stephani 0 siblings, 1 reply; 8+ messages in thread From: Amos Bird @ 2017-06-15 9:04 UTC (permalink / raw) To: Philipp Stephani; +Cc: Emacs developers, Yuri Khan 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. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: goto-address-at-point doesn't get the right url when there is a trailing ')' 2017-06-15 9:04 ` Amos Bird @ 2017-06-15 9:51 ` Philipp Stephani 2017-06-15 13:49 ` Amos Bird 0 siblings, 1 reply; 8+ messages in thread From: Philipp Stephani @ 2017-06-15 9:51 UTC (permalink / raw) To: Amos Bird; +Cc: Emacs developers, Yuri Khan [-- 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 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: goto-address-at-point doesn't get the right url when there is a trailing ')' 2017-06-15 9:51 ` Philipp Stephani @ 2017-06-15 13:49 ` Amos Bird 2017-06-16 16:27 ` Philipp Stephani 0 siblings, 1 reply; 8+ messages in thread From: Amos Bird @ 2017-06-15 13:49 UTC (permalink / raw) To: Philipp Stephani; +Cc: Emacs developers, Yuri Khan 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'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. >> >> > 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 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: goto-address-at-point doesn't get the right url when there is a trailing ')' 2017-06-15 13:49 ` Amos Bird @ 2017-06-16 16:27 ` Philipp Stephani 0 siblings, 0 replies; 8+ messages in thread From: Philipp Stephani @ 2017-06-16 16:27 UTC (permalink / raw) To: Amos Bird; +Cc: Emacs developers, Yuri Khan [-- Attachment #1: Type: text/plain, Size: 3084 bytes --] OK, I've pushed this as 3b6e01cccf89ba0f3485751125f43463bc429345 to master and added a unit test. Amos Bird <amosbird@gmail.com> 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 <p.stephani2@gmail.com> writes: > > > 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. > >> > >> > > 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 > > [-- Attachment #2: Type: text/html, Size: 4605 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2017-06-16 16:27 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [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 2017-06-15 13:49 ` Amos Bird 2017-06-16 16:27 ` Philipp Stephani
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).