Function: org-roam-set-keyword

org-roam-set-keyword is a byte-compiled function defined in org-roam-utils.el.

Signature

(org-roam-set-keyword KEY VALUE)

Documentation

Set keyword KEY to VALUE.

If the property is already set, it's value is replaced.

Source Code

;; Defined in ~/.emacs.d/elpa/org-roam-20260224.1637/org-roam-utils.el
(defun org-roam-set-keyword (key value)
  "Set keyword KEY to VALUE.
If the property is already set, it's value is replaced."
  (org-with-point-at 1
    (let ((case-fold-search t))
      (if (re-search-forward (concat "^#\\+" key ":\\(.*\\)") (point-max) t)
          (if (string-blank-p value)
              (kill-whole-line)
            (replace-match (concat " " value) 'fixedcase nil nil 1))
        (org-roam-end-of-meta-data 'drawers)
        (if (save-excursion (end-of-line) (eobp))
            (progn
              (end-of-line)
              (insert "\n"))
          (forward-line)
          (beginning-of-line))
        (insert "#+" key ": " value "\n")))))