~protesilaos/denote

1

Bug in backlinks search

Details
Message ID
<87jzo56lew.fsf@prevos.net>
DKIM signature
pass
Download raw message
Hi Prot et al.,

I noted that a search for backlinks yields results that are not 
technically links.

As I am experimenting with saving the complete Denote archive as a 
JSON file for visualisation, I noted that the backlinks search 
also returns hits on my notes with embedded JSON snippets, e.g.: 
{"id":"20190402T054953","name":"Adams (1994): The Knot 
Book"}. Denote now suggests a link from the note holding this JSON 
to the referenced note.

I brute-force corrected the denote--retrieve-location-in-xrefs 
function by appending the identifier with "denote:", which works 
in my case.

(defun denote--retrieve-location-in-xrefs (identifier)
    "Return list of xrefs for IDENTIFIER with their respective 
    location.
  Limit the search to text files, per `denote-directory-files' 
  with
  non-nil `text-only' parameter."
    (mapcar #'xref-match-item-location
            ;; Original finds all identifiers, also when not links
            ;; xref-matches-in-files identifier
            (xref-matches-in-files (concat "denote:" identifier)
                                   (denote-directory-files nil nil 
                                   :text-only))))

This is not a very elegant solution as it does not reference the 
link regular expression variables.

This is only an edge-case bug, so I just bringing it to attention.

Regards

P:)


-- 
Dr Peter Prevos
---------------
peterprevos.com
Details
Message ID
<87sf2i6lcy.fsf@protesilaos.com>
In-Reply-To
<87jzo56lew.fsf@prevos.net> (view parent)
DKIM signature
pass
Download raw message
> From: Peter Prevos <peter@prevos.net>
> Date: Sat, 20 Jan 2024 08:45:53 +1100
>
> Hi Prot et al.,

Hello Peter,

> I noted that a search for backlinks yields results that are not 
> technically links.
>
> As I am experimenting with saving the complete Denote archive as a 
> JSON file for visualisation, I noted that the backlinks search 
> also returns hits on my notes with embedded JSON snippets, e.g.: 
> {"id":"20190402T054953","name":"Adams (1994): The Knot 
> Book"}. Denote now suggests a link from the note holding this JSON 
> to the referenced note.

Oh, this is good to know!

> I brute-force corrected the denote--retrieve-location-in-xrefs 
> function by appending the identifier with "denote:", which works 
> in my case.

Yes, this sounds right.

> (defun denote--retrieve-location-in-xrefs (identifier)
>     "Return list of xrefs for IDENTIFIER with their respective 
>     location.
>   Limit the search to text files, per `denote-directory-files' 
>   with
>   non-nil `text-only' parameter."
>     (mapcar #'xref-match-item-location
>             ;; Original finds all identifiers, also when not links
>             ;; xref-matches-in-files identifier
>             (xref-matches-in-files (concat "denote:" identifier)
>                                    (denote-directory-files nil nil 
>                                    :text-only))))
>
> This is not a very elegant solution as it does not reference the 
> link regular expression variables.
>
> This is only an edge-case bug, so I just bringing it to attention.

We can refine the technicalities, but I think you are onto something
here. I will need to review the xrefs mechanism. But I cannot do it now
because I still taking long breaks away from the keyboard.

All the best,
Prot

-- 
Protesilaos Stavrou
https://protesilaos.com
Reply to thread Export thread (mbox)