]> git.donarmstrong.com Git - emacs.git/commitdiff
Add commands to add ids to org mode buffers
authorDon Armstrong <don@donarmstrong.com>
Tue, 18 Mar 2014 04:18:28 +0000 (21:18 -0700)
committerDon Armstrong <don@donarmstrong.com>
Tue, 18 Mar 2014 04:18:28 +0000 (21:18 -0700)
.emacs

diff --git a/.emacs b/.emacs
index 9c7b047e9ce8ff7c4ee1ce04139ce153f38447d5..30f236cdb5f5e404fb5d5cc1ba6e7f5d1f0cd943 100644 (file)
--- a/.emacs
+++ b/.emacs
     (org-remove-empty-drawer-at "LOGBOOK" (point))))
 
 (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
+; add ids on creation of nodes
+(add-hook 'org-capture-prepare-finalize-hook 'org-id-get-create)
+; create function to create headlines in file. This comes from
+; http://stackoverflow.com/questions/13340616/assign-ids-to-every-entry-in-org-mode
+(defun my/org-add-ids-to-headlines-in-file ()
+  "Add ID properties to all headlines in the current file which
+do not already have one."
+  (interactive)
+  (org-map-entries 'org-id-get-create))
+; if we wanted to do this to every buffer, do the following:
+; (add-hook 'org-mode-hook
+;           (lambda ()
+;             (add-hook 'before-save-hook 'my/org-add-ids-to-headlines-in-file nil 'local)))
 
 
 ; resolve clocks after 10 minutes of idle; use xprintidle