On 17 Jul 2024, Ihor Radchenko wrote:
The notion of "URL", and especially "URL at point" in Org mode needs to
be special. Consider something like

[[https://orgmode.org][this is a very long and /convoluted/
description of this url; all the text here is clickable as a link]].

Org mode will consider point anywhere inside the link as "at URL".
That "URL" will be https://orgmode.org, and it is indeed what
(thing-at-point 'url) will return on that link in Org mode, even when
point is on the link description.
Hope it makes sense.

What does not make sense in such scenario is returning
(bounds-of-thing-at-point 'url) to not include point. So, we instead
return the relevant syntax object - link object. And that object
includes description, brackets, and whitespace after.

There is no reason to make plain links special in this regard, so we
don't.

Thank you for the explanation, Ihor.

I'm sure there are people depending on the fact that the rest of the line, after a plain link, is still part of the same node. My code does a manipulation of just the link itself -- for example, in one keystroke, it turns

 https://example.org/

into

 [[https://example.org/][example.org]]

In order for that to work, I needed the bounds to be the start and end of the link text itself. But that was easy to do: I just temporarily override `bounds-of-thing-at-point-provider-alist' in Org Mode, so that I get the default thingatpt handler instead.

So: problem solved.

Best regards,
-Karl

Reply via email to