diff options
| author | BardofSprites <[email protected]> | 2025-08-21 20:20:55 -0400 |
|---|---|---|
| committer | BardofSprites <[email protected]> | 2025-08-21 20:20:55 -0400 |
| commit | a518b23058426f9936ac08b36f06065408249b34 (patch) | |
| tree | 5ea173d4aa8eeb6237d48c35a83c3acf2487b2d3 /bard-elisp/bard-writing.el | |
| parent | 04f13418111548612fc871e1db303a65c411298d (diff) | |
tweaks for use in org-roam
Diffstat (limited to 'bard-elisp/bard-writing.el')
| -rw-r--r-- | bard-elisp/bard-writing.el | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/bard-elisp/bard-writing.el b/bard-elisp/bard-writing.el index f5b9079..4861b5a 100644 --- a/bard-elisp/bard-writing.el +++ b/bard-elisp/bard-writing.el @@ -1,3 +1,20 @@ +(defun bard/denote-insert-id-at-top () + "Insert or replace a top-level :ID: property at the very top of the current file." + (interactive) + (org-with-wide-buffer + (goto-char (point-min)) + ;; If file already starts with a :PROPERTIES: drawer, remove it + (when (looking-at ":PROPERTIES:") + (let ((end (save-excursion + (re-search-forward ":END:" nil t)))) + (when end + (delete-region (point-min) (min (point-max) (1+ end))))))) + ;; Insert fresh ID drawer at very top + (goto-char (point-min)) + (let ((id (org-id-new))) + (insert (format ":PROPERTIES:\n:ID: %s\n:END:\n" id))) + (save-buffer)) + (defun denote-sequence-region () "Call `denote-sequence' and insert therein the text of the active region. |
