adjust automatic add of archive property to entries -- now applies to all items in a file whenever the file is saved -- tweak auto-org-id method to be less code
This commit is contained in:
parent
c8dc9e9f02
commit
f0497a5370
|
@ -10,23 +10,6 @@
|
|||
'(("TODO" . "turquoise") ("READY" . "yellow") ("WIP" . "magenta") ("COMPLETE" . "green") ("CANCELED" . "orange"))
|
||||
)
|
||||
|
||||
; mangle the 'ARCHIVE' property of todo's so they archive off to a year/month.org file when complete
|
||||
(defun my/org-set-archive-prop-for-todo ()
|
||||
(interactive)
|
||||
(org-set-property "ARCHIVE" (concat
|
||||
"~/org/Attic/org-mode/%s/"
|
||||
(format-time-string "%Y" (current-time))
|
||||
"/"
|
||||
(format-time-string "%m" (current-time))
|
||||
".archive.org::datetree/"
|
||||
)
|
||||
))
|
||||
|
||||
; hooks to auto manage todo 'ARCHIVE' property
|
||||
(add-hook 'org-after-todo-state-change-hook 'my/org-set-archive-prop-for-todo)
|
||||
; auto archive complete todo items
|
||||
;(add-hook 'org-mode-hook (lambda () (add-hook 'after-save-hook 'org-archive-all-done nil t)))
|
||||
|
||||
(setq org-tags-exclude-from-inheritance (quote ("@recipe" "@budgetbytes"
|
||||
"@vegan" "@vegetarian"
|
||||
"@instapot" "@slowcooker" "@onepot" "@oven" "@baked" "@baking" "@dehydrator" "@ricecooker"
|
||||
|
|
36
org/init.el
36
org/init.el
|
@ -127,20 +127,41 @@
|
|||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; automatic ids for everything
|
||||
; From https://web.archive.org/web/20220512120917/https://stackoverflow.com/questions/13340616/assign-ids-to-every-entry-in-org-mode
|
||||
; From https://stackoverflow.com/questions/13340616/assign-ids-to-every-entry-in-org-mode
|
||||
; This hunk of lisp automatically adds IDs to every header in an org file when you hit save. it usese org-id which can generated IDs of various types including timestamps. I’m using the default UUIDs
|
||||
(defun stackoverflow/org-add-ids-to-headlines-in-file ()
|
||||
"cargo cult from stackoverflow to add ids"
|
||||
(interactive)
|
||||
(save-excursion
|
||||
(goto-char (point-max))
|
||||
(while (outline-previous-heading)
|
||||
(org-id-get-create)))
|
||||
)
|
||||
(add-hook 'org-mode-hook
|
||||
(org-map-entries 'org-id-get-create)
|
||||
)
|
||||
(add-hook 'org-mode-hook
|
||||
(lambda ()
|
||||
(add-hook 'before-save-hook 'stackoverflow/org-add-ids-to-headlines-in-file nil 'local)))
|
||||
(add-hook 'org-capture-prepare-finalize-hook 'org-id-get-create)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; keep 'ARCHIVE' property up to date for entire buffer so any archives are filed in 'todays' archive
|
||||
; assumes you want archive dates to be the date of the archive operation, not the last time they were 'touched' (or created)
|
||||
(defun kmn/org-set-archive-prop-for-todo ()
|
||||
(interactive)
|
||||
(save-excursion
|
||||
(goto-char (point-max))
|
||||
(while (outline-previous-heading)
|
||||
(org-set-property "ARCHIVE" (concat
|
||||
"~/org/Attic/org-mode/%s/"
|
||||
(format-time-string "%Y" (current-time))
|
||||
"/"
|
||||
(format-time-string "%m" (current-time))
|
||||
".archive.org::datetree/"
|
||||
))
|
||||
))
|
||||
)
|
||||
|
||||
(add-hook 'org-mode-hook
|
||||
(lambda ()
|
||||
(add-hook 'before-save-hook 'kmn/org-set-archive-prop-for-todo nil 'local)))
|
||||
(add-hook 'org-capture-prepare-finalize-hook 'kmn/org-set-archive-prop-for-todo)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; ox-hugo for blog
|
||||
(with-eval-after-load 'ox (require 'ox-hugo))
|
||||
|
@ -285,4 +306,5 @@
|
|||
(eval add-hook 'after-save-hook 'org-html-export-to-html t t)
|
||||
(eval add-hook 'after-save-hook 'org-gfm-export-to-markdown t t)))
|
||||
'(temp-buffer-resize-mode t)
|
||||
'(zoom-ignored-major-modes '(dired-mode)))
|
||||
'(zoom-ignored-major-modes '(dired-mode))
|
||||
'(zoom-size 'kmn-zoom-size-callback))
|
||||
|
|
Reference in a new issue