#+PROPERTY: header-args:emacs-lisp :tangle don-configuration.el
+#+OPTIONS: auto-id:f
* Load debugger
# if for some reason, things get pear-shaped, we want to be able to
(setq org-use-fast-todo-selection t)
(setq org-treat-S-cursor-todo-selection-as-state-change nil)
- ; 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))
- (defun dla/org-update-ids-to-headlines-in-file ()
- "Add or replace ID properties to all headlines in the current file
- (or narrowed region)."
- (interactive)
- (org-map-entries '(lambda () (org-id-get-create t))))
- ; 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)))
+; 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)
+ (save-excursion
+ (widen)
+ (goto-char (point-min))
+ (when (not (re-search-forward "^#\\+OPTIONS:.*auto-id:f" (point-max) t))
+ (org-map-entries 'org-id-get-create))))
+(defun dla/org-update-ids-to-headlines-in-file ()
+ "Add or replace ID properties to all headlines in the current file
+(or narrowed region)."
+ (interactive)
+
+ (org-map-entries '(lambda () (org-id-get-create t))))
+; 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)))
#+END_SRC
** Org ID locations
#+BEGIN_SRC emacs-lisp