emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: goto-address-at-point doesn't get the right url when there is a trai


From: Amos Bird
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
User-agent: mu4e 0.9.19; emacs 25.2.2

Thanks Philipp! I did some tests and it works quite well.

regards,
Amos

Philipp Stephani <address@hidden> writes:

> The attached patch appears to do the right thing for me (but I haven't
> tested it extensively).
>
> Amos Bird <address@hidden> 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 <address@hidden> writes:
>>
>> > Yuri Khan <address@hidden> schrieb am Mi., 14. Juni 2017 um
>> > 17:03 Uhr:
>> >
>> >> On Wed, Jun 14, 2017 at 5:11 PM, Amos Bird <address@hidden> 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 <address@hidden>
> 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]