On Thu, Apr 21, 2022 at 12:23 PM tony aldon <tony.aldon.adm@gmail.com> wrote:
You're right I was effectively missing affiliated keywords and so my
patch is wrong.

Thank you for your quick feedback and insight.

Have a nice day,
Tony Aldon

On Thu, Apr 21, 2022 at 7:39 AM Ihor Radchenko <yantar92@gmail.com> wrote:
tony aldon <tony.aldon.adm@gmail.com> writes:

> If I'm not wrong, name defined after #+NAME: should be match first
> before trying a fuzzy search in the function `org-link-search`.
> ...
> -                     (name (org-element-property :name element)))
> +                     (name (org-element-property :value element)))

I think you are missing something.

A standaline

#+name: some name

is a keyword, not an element name, but a generic keyword element.

Named elements are the elements with affiliated keywords (not ordinary
keywords):

#+name: some other name
Some element that can have affiliated keywords. It may be a paragraph,
like here or e.g. source block. Link search should not try to search
standalone keywords and hence it is sufficient to check for :name
element property. :value will miss e.g. named source blocks.

Try running (org-element-at-point) on the first and second #+name in org
buffer.

Best,
Ihor