From: Jim Porter <jporterbugs@gmail.com>
To: Ihor Radchenko <yantar92@posteo.net>, emacs-devel@gnu.org
Cc: emacs-orgmode@gnu.org
Subject: Re: Adding custom providers for thingatpt.el (was: [PATCH] Add support for 'thing-at-point' to get URL at point)
Date: Mon, 6 Nov 2023 12:53:02 -0800 [thread overview]
Message-ID: <88435424-afa3-d7a3-56ff-df9f0a2ca6ba@gmail.com> (raw)
In-Reply-To: <87leba3ame.fsf@localhost>
On 11/6/2023 12:11 PM, Ihor Radchenko wrote:
> [ Branching to emacs-devel for further input from Emacs devs ]
>
> Jim Porter <jporterbugs@gmail.com> writes:
>
>> This is similar to Emacs bug#66752[1]. It would be nice if
>> "(thing-at-point 'url)" would return the URL when point is over an Org
>> link. With this, it's easier to write a function that copies (or browses
>> to) the URL at point without coding so many special cases.
>> ...
>> +(defun org--url-at-point ()
>> + "`thing-at-point' provider function."
>> + (org-element-property :raw-link (org-element-context)))
>
> Supporting thingatpt.el is certainly welcome. However, I have some
> doubts about how mature thingatpt.el is.
>
> In particular, I am concerned whether `thing-at-point-provider-alist' is
> reliable enough in non-trivial scenarios like when given URL string is
> not matching some generic URL regexp.
The nice thing about 'thing-at-point-provider-alist' is that your
provider has absolute control over what to return, so Org's URL provider
could do whatever it wants. As far as I can tell, this code path
completely avoids calling 'bounds-of-thing-at-point' ('botap'). However,
it *would* call 'botap' if point wasn't on an Org link, since it would
fall back to the last condition in 'thing-at-point'. Still, this is what
happens today with no provider, so it's not really any worse than before...
Maybe it would make sense for 'thing-at-point' to have a "(catch
'not-found ...)" form around the loop over
'thing-at-point-provider-alist'. Then Org could definitively say,
"There's no URL at point, no matter what anyone else says".
> Looking into the source code of `bounds-of-thing-at-point', I see that
> for standard "things" (like url),
> `thing-at-point-bounds-of-url-at-point' is used unconditionally. In the
> case of Org links, we may have something like [<point>[https://orgmode.org]]
> that will not match default URL regexp as is. AFAIU, there is no
> documented way to customize the behaviour of `bounds-of-thing-at-point'
> and `forward-thing'.
I think it would make sense to add some sort of
'bounds-of-thing-at-point-provider-alist' (that's a mouthful!) that
would let modes override the behavior of 'botap', but I don't think
that's necessary for the narrower purpose of asking, "I want the value
of THING at point, if any."
> I also have concerns about Org-specific part of the patch, but the above
> is far more important, and we need to discuss it before starting to
> consider anything for Org mode.
For better or worse, I mostly modeled this patch on how EWW integrates
with thing-at-point, since that's the only place I saw in the Emacs tree
that did this already.
next prev parent reply other threads:[~2023-11-06 20:53 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <abbf9444-7bc7-83f1-f48a-632f4d7a6154@gmail.com>
2023-11-06 20:11 ` Adding custom providers for thingatpt.el (was: [PATCH] Add support for 'thing-at-point' to get URL at point) Ihor Radchenko
2023-11-06 20:53 ` Jim Porter [this message]
2024-02-05 15:07 ` Ihor Radchenko
2024-02-05 22:44 ` Jim Porter
2024-02-05 22:56 ` Ihor Radchenko
2024-02-06 12:26 ` Eli Zaretskii
2024-02-06 12:38 ` Ihor Radchenko
2024-02-06 12:47 ` Eli Zaretskii
2024-04-12 12:41 ` Ihor Radchenko
2024-04-12 22:30 ` Jim Porter
2024-04-29 4:26 ` Jim Porter
2024-04-29 18:14 ` Ihor Radchenko
2024-04-30 4:42 ` Jim Porter
2024-04-30 11:39 ` Ihor Radchenko
2024-04-30 18:27 ` Jim Porter
2024-04-30 21:10 ` [External] : " Drew Adams
2024-05-07 1:08 ` Jim Porter
2024-05-07 1:52 ` Drew Adams
2024-05-07 12:20 ` Eli Zaretskii
2024-05-07 15:16 ` Drew Adams
2024-05-07 16:10 ` Jim Porter
2024-05-07 18:01 ` Eli Zaretskii
2024-05-18 8:26 ` Eli Zaretskii
2024-05-20 1:34 ` Jim Porter
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=88435424-afa3-d7a3-56ff-df9f0a2ca6ba@gmail.com \
--to=jporterbugs@gmail.com \
--cc=emacs-devel@gnu.org \
--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.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).