[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Adding custom providers for thingatpt.el (was: [PATCH] Add support for '
From: |
Ihor Radchenko |
Subject: |
Adding custom providers for thingatpt.el (was: [PATCH] Add support for 'thing-at-point' to get URL at point) |
Date: |
Mon, 06 Nov 2023 20:11:37 +0000 |
[ 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.
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 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.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>