Function: hywiki-add-denote

hywiki-add-denote is an interactive and byte-compiled function defined in hywiki.el.

Signature

(hywiki-add-denote WIKIWORD)

Documentation

Make WIKIWORD display a denote file when the denote package is available.

When called interactively or with WIKIWORD nil or the empty string, then set WIKIWORD to any wikiword at or immediately before point; otherwise, convert the description from the denote file chosen to be the WIKIWORD and insert that after any non-whitespace text at point.

After successfully adding the link to a denote file, run hywiki-add-referent-hook.

Return the WIKIWORD referent if WIKIWORD is of valid format, otherwise return nil. The referent is a cons of (denote-description . denote-id).

Use hywiki-get-referent to determine whether WIKIWORD exists prior to calling this function.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260822.1645/hywiki.el
(defun hywiki-add-denote (wikiword)
  "Make WIKIWORD display a denote file when the `denote' package is available.
When called interactively or with WIKIWORD nil or the empty string, then set
WIKIWORD to any wikiword at or immediately before point; otherwise, convert
the description from the denote file chosen to be the WIKIWORD and insert
that after any non-whitespace text at point.

After successfully adding the link to a denote file, run
`hywiki-add-referent-hook'.

Return the WIKIWORD referent if WIKIWORD is of valid format, otherwise
return nil.  The referent is a cons of (denote-description . denote-id).

Use `hywiki-get-referent' to determine whether WIKIWORD exists prior to
calling this function."
  (interactive (list nil))
  (hypb:require-package 'denote)
  (let ((at-wikiword-reference (hywiki-word-at)))
    (unless (and (stringp wikiword) (not (string-empty-p wikiword)))
      (setq wikiword at-wikiword-reference))
    (let* ((denote-file (denote-file-prompt
                         nil
                         (if (stringp wikiword)
                             (format "Link `%s' HyWikiWord to denote" wikiword)
                           ;; Will use denote file description as `wikiword'
                           "Add HyWikiWord denote link to")
                         nil t))
           (denote-desc (denote-get-link-description denote-file))
           (denote-id (denote-retrieve-filename-identifier denote-file)))
      (unless (and (stringp wikiword) (not (string-empty-p wikiword)))
        (setq wikiword (hywiki-string-to-wikiword denote-desc)))
      (unless (hyperb:stack-frame '(hywiki-create-referent-and-display))
        (unless (equal (hywiki-get-singular-wikiword wikiword)
                       (hywiki-get-singular-wikiword at-wikiword-reference))
          (if buffer-read-only
              (error "(hywiki-add-denote): Read-only buffer; call this with point on: \"%s\"" wikiword)
            (skip-syntax-forward "^-")
            (unless (or (bolp) (= (char-syntax (preceding-char)) ?\ ))
              (insert " "))
            (insert wikiword))))
      (hywiki-add-referent wikiword (cons 'denote (cons denote-desc denote-id))))))