aboutsummaryrefslogtreecommitdiff
path: root/bard-elisp
diff options
context:
space:
mode:
Diffstat (limited to 'bard-elisp')
-rw-r--r--bard-elisp/bard-writing.el17
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.