Archived
1
0
Fork 0

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:
KemoNine 2024-07-28 12:04:49 -04:00
parent c8dc9e9f02
commit f0497a5370
2 changed files with 52 additions and 47 deletions

View file

@ -10,23 +10,6 @@
'(("TODO" . "turquoise") ("READY" . "yellow") ("WIP" . "magenta") ("COMPLETE" . "green") ("CANCELED" . "orange")) '(("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" (setq org-tags-exclude-from-inheritance (quote ("@recipe" "@budgetbytes"
"@vegan" "@vegetarian" "@vegan" "@vegetarian"
"@instapot" "@slowcooker" "@onepot" "@oven" "@baked" "@baking" "@dehydrator" "@ricecooker" "@instapot" "@slowcooker" "@onepot" "@oven" "@baked" "@baking" "@dehydrator" "@ricecooker"

View file

@ -127,20 +127,41 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; automatic ids for everything ; 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://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. Im using the default UUIDs ; 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. Im using the default UUIDs
(defun stackoverflow/org-add-ids-to-headlines-in-file () (defun stackoverflow/org-add-ids-to-headlines-in-file ()
"cargo cult from stackoverflow to add ids" "cargo cult from stackoverflow to add ids"
(interactive) (interactive)
(save-excursion (org-map-entries 'org-id-get-create)
(goto-char (point-max)) )
(while (outline-previous-heading) (add-hook 'org-mode-hook
(org-id-get-create))) (lambda ()
) (add-hook 'before-save-hook 'stackoverflow/org-add-ids-to-headlines-in-file nil 'local)))
(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) (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 ; ox-hugo for blog
(with-eval-after-load 'ox (require 'ox-hugo)) (with-eval-after-load 'ox (require 'ox-hugo))
@ -264,25 +285,26 @@
(which-key all-the-icons revert-buffer-all centaur-tabs scratch persistent-scratch persp-mode rainbow-mode rainbow-delimiters markdown-mode focus zoom popwin dired-single diredfl doominhibitinhibit-modeline helpful helm helm-org dired-rainbow dired-rainbow-listing dired-single dash s origami modus-themes use-package))) (which-key all-the-icons revert-buffer-all centaur-tabs scratch persistent-scratch persp-mode rainbow-mode rainbow-delimiters markdown-mode focus zoom popwin dired-single diredfl doominhibitinhibit-modeline helpful helm helm-org dired-rainbow dired-rainbow-listing dired-single dash s origami modus-themes use-package)))
'(safe-local-variable-values '(safe-local-variable-values
'((org-auto-expand-nodes '((org-auto-expand-nodes
(("To Do") (("To Do")
body 1) body 1)
(("Daily / Weekly Reset") (("Daily / Weekly Reset")
children 2)) children 2))
(org-auto-expand-nodes (org-auto-expand-nodes
(("Daily / Weekly Reset") (("Daily / Weekly Reset")
body 2)) body 2))
(eval org-auto-expand) (eval org-auto-expand)
(org-auto-expand-nodes (org-auto-expand-nodes
(("To Do") (("To Do")
body 1)) body 1))
(eval setq org-html-postamble nil) (eval setq org-html-postamble nil)
(eval setq org-export-html-postamble-format nil) (eval setq org-export-html-postamble-format nil)
(eval add-hook 'after-save-hook 'org-pandoc-export-to-latex-pdf t t) (eval add-hook 'after-save-hook 'org-pandoc-export-to-latex-pdf t t)
(eval add-hook 'after-save-hook 'org-pandoc-export-to-docx t t) (eval add-hook 'after-save-hook 'org-pandoc-export-to-docx t t)
(eval add-hook 'after-save-hook 'org-ascii-export-to-ascii t t) (eval add-hook 'after-save-hook 'org-ascii-export-to-ascii t t)
(eval add-hook 'after-save-hook 'org-md-export-to-markdown t t) (eval add-hook 'after-save-hook 'org-md-export-to-markdown t t)
(eval add-hook 'after-save-hook 'org-org-export-to-org t t) (eval add-hook 'after-save-hook 'org-org-export-to-org t t)
(eval add-hook 'after-save-hook 'org-html-export-to-html t t) (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))) (eval add-hook 'after-save-hook 'org-gfm-export-to-markdown t t)))
'(temp-buffer-resize-mode t) '(temp-buffer-resize-mode t)
'(zoom-ignored-major-modes '(dired-mode))) '(zoom-ignored-major-modes '(dired-mode))
'(zoom-size 'kmn-zoom-size-callback))