[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Adding custom providers for thingatpt.el (was: [PATCH] Add support f
From: |
Eli Zaretskii |
Subject: |
Re: Adding custom providers for thingatpt.el (was: [PATCH] Add support for 'thing-at-point' to get URL at point) |
Date: |
Tue, 06 Feb 2024 14:47:32 +0200 |
> From: Ihor Radchenko <yantar92@posteo.net>
> Cc: jporterbugs@gmail.com, stefankangas@gmail.com, emacs-devel@gnu.org,
> emacs-orgmode@gnu.org
> Date: Tue, 06 Feb 2024 12:38:19 +0000
>
> Eli Zaretskii <eliz@gnu.org> writes:
>
> > I think we do want to allow extending of this, but doesn't
> > thingatpt.el already provide such capabilities? For example, I see
> > this in bounds-of-thing-at-point:
> > ...
> > (cond
> > ((get thing 'bounds-of-thing-at-point) <<<<<<<<<<<<<<<<<<<<<<<<
> > (funcall (get thing 'bounds-of-thing-at-point)))
> >
> > Doesn't this provide the extension capabilities you are looking for?
> > If not, why not?
>
> Unlike `thing-at-point-provider-alist', which can be buffer-local,
> symbol property is always global and setting it would override other
> thing providers.
>
> Note how `thing-at-point' uses
>
> (cond
> ((let ((alist thing-at-point-provider-alist)
> elt result)
> (while (and alist (null result))
> (setq elt (car alist)
> alist (cdr alist))
> (and (eq (car elt) thing)
> (setq result (funcall (cdr elt)))))
> result))
> ((get thing 'thing-at-point)
> (funcall (get thing 'thing-at-point)))
>
> checking `thing-at-point-provider-alist' and only then falling back to
> `get'. What I am proposing is to add the equivalent alists for other
> operators used by thingatpt.el.
I guess it's fine, then.
But we probably should have such alists in all the other thingatpt
methods as well.