emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Karl Fogel <kfogel@red-bean.com>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: Possible bug getting bounds of URL at point?
Date: Wed, 17 Jul 2024 12:05:36 -0500	[thread overview]
Message-ID: <87wmlk9cf3.fsf@red-bean.com> (raw)
In-Reply-To: <87cync6q4g.fsf@localhost> (Ihor Radchenko's message of "Wed, 17 Jul 2024 14:37:51 +0000")

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	other threads:[~2024-07-17 17:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-16 20:10 Possible bug getting bounds of URL at point? Karl Fogel
2024-07-16 20:21 ` Ihor Radchenko
2024-07-16 20:34   ` Karl Fogel
2024-07-17 14:37     ` Ihor Radchenko
2024-07-17 17:05       ` Karl Fogel [this message]

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.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wmlk9cf3.fsf@red-bean.com \
    --to=kfogel@red-bean.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=yantar92@posteo.net \
    /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/org-mode.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).