Function: denote-link-or-create

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

Signature

(denote-link-or-create TARGET &optional ID-ONLY)

Documentation

Use denote-link on TARGET file, creating it if necessary.

If TARGET file does not exist, call denote-link-after-creating which runs the denote command interactively to create the file. The established link will then be targeting that new file. In that case, use the last input at the file prompt as the default value of the title prompt.

With optional ID-ONLY as a prefix argument create a link that consists of just the identifier. Else try to also include the file's title. This has the same meaning as in denote-link.

Key Bindings

Aliases

denote-link-to-existing-or-new-note

Source Code

;; Defined in ~/.emacs.d/elpa/denote-4.2.3/denote.el
;;;###autoload
(defun denote-link-or-create (target &optional id-only)
  "Use `denote-link' on TARGET file, creating it if necessary.

If TARGET file does not exist, call `denote-link-after-creating' which
runs the `denote' command interactively to create the file.  The
established link will then be targeting that new file.  In that case,
use the last input at the file prompt as the default value of the title
prompt.

With optional ID-ONLY as a prefix argument create a link that
consists of just the identifier.  Else try to also include the
file's title.  This has the same meaning as in `denote-link'."
  (interactive
   (let* ((target (denote-file-prompt nil "Select file (RET on no match to create it)" :no-require-match :has-identifier)))
     (unless (and target (file-exists-p target))
       (setq target (denote--command-with-features #'denote :use-file-prompt-as-def-title :ignore-region :save :in-background)))
     (list target 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"))
  (denote-link target
               (denote-filetype-heuristics (buffer-file-name))
               (denote-get-link-description target)
               id-only))