Function: denote-link-dired-marked-notes

denote-link-dired-marked-notes is an autoloaded, interactive and byte-compiled function defined in denote.el.

Signature

(denote-link-dired-marked-notes FILES BUFFER &optional ID-ONLY)

Documentation

Insert Dired marked FILES as links in BUFFER.

FILES conform with the Denote file-naming scheme, such that they can be linked to using the denote: link type.

The BUFFER is one which visits a Denote note file. If there are multiple BUFFER candidates in buffers, prompt with completion for one among them. If there is none, throw an error.

With optional ID-ONLY as a prefix argument, insert links with just the identifier (same principle as with denote-link).

This command is meant to be used from a Dired buffer.

Key Bindings

Aliases

denote-dired-link-marked-notes

Source Code

;; Defined in ~/.emacs.d/elpa/denote-4.2.3/denote.el
;;;###autoload
(defun denote-link-dired-marked-notes (files buffer &optional id-only)
  "Insert Dired marked FILES as links in BUFFER.

FILES conform with the Denote file-naming scheme, such that they can be
linked to using the `denote:' link type.

The BUFFER is one which visits a Denote note file.  If there are
multiple BUFFER candidates in buffers, prompt with completion for
one among them.  If there is none, throw an error.

With optional ID-ONLY as a prefix argument, insert links with
just the identifier (same principle as with `denote-link').

This command is meant to be used from a Dired buffer."
  (interactive
   (if (derived-mode-p 'dired-mode)
       (list
        (denote-link--map-over-notes)
        (let ((file-names (denote--buffer-file-names)))
          (find-buffer-visiting
           (cond
            ((null file-names)
             (user-error "No buffers visiting Denote notes"))
            ((eq (length file-names) 1)
             (car file-names))
            (t
             (denote-link--buffer-file-prompt file-names)))))
        current-prefix-arg)
     (user-error "This command only works inside a Dired buffer"))
   dired-mode)
  (when (null files)
    (user-error "No note files to link to"))
  (unless (buffer-live-p buffer)
    (error "The buffer `%s' is not live" buffer))
  (let ((body (lambda ()
                (unless (or (denote--file-type-org-extra-p)
                            (and buffer-file-name (denote-file-has-supported-extension-p buffer-file-name)))
                  (user-error "The target file's type is not recognized by Denote"))
                (when (y-or-n-p (format "Create links at point in `%s'?" buffer))
                  (denote-link--insert-links files (denote-filetype-heuristics buffer-file-name) id-only)
                  (message "Added links to `%s'; displaying it now"
                           ;; TODO 2024-12-26: Do we need our face here?  I think
                           ;; not, but let me keep a note of it.
                           (propertize (format "%s" buffer) 'face 'success))))))
    (if-let* ((window (get-buffer-window buffer))
              ((window-live-p window)))
        (with-selected-window window (funcall body))
      (with-current-buffer buffer (funcall body))
      (display-buffer-below-selected buffer nil))))