Function: denote-retrieve-xref-alist-for-backlinks

denote-retrieve-xref-alist-for-backlinks is a byte-compiled function defined in denote.el.

Signature

(denote-retrieve-xref-alist-for-backlinks IDENTIFIER)

Documentation

Return xref alist of absolute file paths of matches for IDENTIFIER.

Source Code

;; Defined in ~/.emacs.d/elpa/denote-4.2.3/denote.el
(defun denote-retrieve-xref-alist-for-backlinks (identifier)
  "Return xref alist of absolute file paths of matches for IDENTIFIER."
  (let* ((files (denote-directory-files))
         (file-types (denote--file-type-keys))
         (xref-file-name-display 'abs)
         (xref-matches '()))
    (when-let* ((backlinks (gethash identifier (denote--get-all-backlinks files))))
      (let* ((backlinks-by-file-type (denote--get-files-by-file-type backlinks)))
        (dolist (file-type file-types)
          (when-let* ((current-backlinks (gethash file-type backlinks-by-file-type))
                      (type (denote--link-retrieval-format file-type))
                      (format-parts (split-string type "%VALUE%")) ; Should give two parts
                      (query-simple (concat
                                     (regexp-quote (nth 0 format-parts))
                                     (regexp-quote identifier)
                                     (regexp-quote (nth 1 format-parts))))
                      (query-org-link (concat
                                       (regexp-quote (nth 0 format-parts))
                                       (regexp-quote identifier)
                                       "::")))
            (setq xref-matches (append xref-matches (xref-matches-in-files query-simple current-backlinks)))
            (setq xref-matches (append xref-matches (xref-matches-in-files query-org-link current-backlinks))))))
      (let ((data (xref--analyze xref-matches)))
        (if-let* ((sort denote-query-sorting)
                  (files-matched (mapcar #'car data))
                  (files-sorted (denote-sort-files files-matched sort)))
            (mapcar (lambda (x) (assoc x data)) files-sorted)
          data)))))