Function: denote-link

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

Signature

(denote-link FILE FILE-TYPE DESCRIPTION &optional ID-ONLY)

Documentation

Create link to FILE note in variable denote-directory(var)/denote-directory(fun) with DESCRIPTION.

When called interactively, prompt for FILE using completion. In this case, derive FILE-TYPE from the current buffer. FILE-TYPE is used to determine the format of the link.

Return the DESCRIPTION of the link in the format specified by denote-link-description-format. The default is to return the text of the active region or the title of the note (plus the signature if present).

With optional ID-ONLY as a non-nil argument, such as with a universal prefix (C-u (universal-argument)), insert links with just the identifier and no further description. In this case, the link format is always
[[denote:IDENTIFIER]].

If the DESCRIPTION is empty, format the link the same as with ID-ONLY.

When called from Lisp, FILE is a string representing a full file system path. FILE-TYPE is a symbol as described in the user option denote-file-type(var)/denote-file-type(fun). DESCRIPTION is a string. Whether the caller treats the active region specially, is up to it.

Key Bindings

Aliases

denote-insert-link

Source Code

;; Defined in ~/.emacs.d/elpa/denote-4.2.3/denote.el
;;;###autoload
(defun denote-link (file file-type description &optional id-only)
  "Create link to FILE note in variable `denote-directory' with DESCRIPTION.

When called interactively, prompt for FILE using completion.  In this
case, derive FILE-TYPE from the current buffer.  FILE-TYPE is used to
determine the format of the link.

Return the DESCRIPTION of the link in the format specified by
`denote-link-description-format'.  The default is to return the text of
the active region or the title of the note (plus the signature if
present).

With optional ID-ONLY as a non-nil argument, such as with a universal
prefix (\\[universal-argument]), insert links with just the identifier
and no further description.  In this case, the link format is always
[[denote:IDENTIFIER]].

If the DESCRIPTION is empty, format the link the same as with ID-ONLY.

When called from Lisp, FILE is a string representing a full file system
path.  FILE-TYPE is a symbol as described in the user option
`denote-file-type'.  DESCRIPTION is a string.  Whether the caller treats
the active region specially, is up to it."
  (interactive
   (let* ((file (denote-file-prompt nil "Link to FILE" nil :has-identifier))
          (file-type (denote-filetype-heuristics buffer-file-name))
          (description (when (file-exists-p file)
                         (denote-get-link-description file))))
     (list file file-type description current-prefix-arg)))
  (unless (or (denote--file-type-org-extra-p)
              (and buffer-file-name (denote-file-has-supported-extension-p buffer-file-name)))
    (user-error "The current file type is not recognized by Denote"))
  (unless (file-exists-p file)
    (user-error "The linked file does not exist"))
  (denote--delete-active-region-content)
  (insert (denote-format-link file description file-type id-only)))