Function: denote-get-links

denote-get-links is a byte-compiled function defined in denote.el.

Signature

(denote-get-links &optional FILE FILES)

Documentation

Return list of links in current or optional FILE.

With optional FILES, consider only those, otherwise use the return value of denote-directory-files.

Also see denote-get-backlinks.

Aliases

denote-link-return-links (obsolete since 4.1.0)

Source Code

;; Defined in ~/.emacs.d/elpa/denote-4.2.3/denote.el
(defun denote-get-links (&optional file files)
  "Return list of links in current or optional FILE.
With optional FILES, consider only those, otherwise use the return value
of `denote-directory-files'.

Also see `denote-get-backlinks'."
  (when-let* ((current-file (or file (buffer-file-name)))
              ((denote-file-has-supported-extension-p current-file))
              (file-type (denote-filetype-heuristics current-file))
              (regexp (denote--link-in-context-regexp file-type))
              (files (or files (denote-directory-files nil nil nil nil :has-identifier)))
              (file-identifiers
               (with-temp-buffer
                 (insert-file-contents current-file)
                 (denote-link--collect-identifiers regexp)))
              (file-identifiers-hash-table (make-hash-table :test #'equal)))
    (dolist (id file-identifiers)
      (puthash id t file-identifiers-hash-table))
    (let ((found-files))
      (dolist (file files)
        (when (gethash (denote-retrieve-filename-identifier file) file-identifiers-hash-table)
          (push file found-files)))
      found-files)))