ADD function to insert links for action items

This commit is contained in:
Nathan Dwarshuis 2021-09-24 21:54:22 -04:00
parent 92505ac802
commit 53f561ad63
1 changed files with 18 additions and 10 deletions

View File

@ -1156,11 +1156,12 @@ function will simply return the point of the next headline."
(and (org-ml-is-type 'drawer node) (and (org-ml-is-type 'drawer node)
(equal (org-ml-get-property :drawer-name node) name))) (equal (org-ml-get-property :drawer-name node) name)))
(defun org-x-headline-meeting-add-agenda-item () ;; TODO try to make agenda come before action
"Add a linked headline to the agenda items of the current headline. (defun org-x--headline-meeting-add-link (dname checkbox)
"Add a linked headline to drawer with DNAME under the current headline.
Only ID links are considered. Headline must be a meeting (tagged Only ID links are considered. Headline must be a meeting (tagged
with proper todo keywords)." with proper todo keywords). If CHECKBOX is non-nil, add item with
(interactive) an empty checkbox."
(if (not (org-x-headline-is-meeting-p)) (if (not (org-x-headline-is-meeting-p))
(message "Not in a meeting headline") (message "Not in a meeting headline")
(-if-let (id-alist (->> org-stored-links (-if-let (id-alist (->> org-stored-links
@ -1173,12 +1174,10 @@ with proper todo keywords)."
(alist-get id-alist nil nil #'equal))) (alist-get id-alist nil nil #'equal)))
(item* (->> (org-ml-build-link id desc) (item* (->> (org-ml-build-link id desc)
(org-ml-build-paragraph) (org-ml-build-paragraph)
(org-ml-build-item :checkbox 'off)))) (org-ml-build-item :checkbox (when checkbox 'off)))))
(org-ml-update-this-headline* (org-ml-update-this-headline*
(org-ml-headline-map-contents* (org-x-logbook-config) (org-ml-headline-map-contents* (org-x-logbook-config)
(-if-let (i (--find-index (-if-let (i (--find-index (org-x--is-drawer-with-name dname it) it))
(org-x--is-drawer-with-name "AGENDA_ITEMS" it)
it))
(let ((drawer* (org-ml-map-children* (let ((drawer* (org-ml-map-children*
(-let* (((all &as x . xs) it)) (-let* (((all &as x . xs) it))
(if (org-ml-is-type 'plain-list x) (if (org-ml-is-type 'plain-list x)
@ -1190,14 +1189,23 @@ with proper todo keywords)."
(nth i it)))) (nth i it))))
(-replace-at i drawer* it)) (-replace-at i drawer* it))
(let ((drawer* (->> (org-ml-build-plain-list item*) (let ((drawer* (->> (org-ml-build-plain-list item*)
(org-ml-build-drawer (org-ml-build-drawer dname))))
:drawer-name "AGENDA_ITEMS"))))
(cons drawer* it))) (cons drawer* it)))
it)) it))
(setq org-stored-links (delq (assoc id org-stored-links) (setq org-stored-links (delq (assoc id org-stored-links)
org-stored-links))) org-stored-links)))
(message "No stored IDs to insert")))) (message "No stored IDs to insert"))))
(defun org-x-headline-meeting-add-agenda-item ()
"Add a link to headline in agenda items for current headline."
(interactive)
(org-x--headline-meeting-add-link "AGENDA_ITEMS" t))
(defun org-x-headline-meeting-add-action-item ()
"Add a link to headline in action items for current headline."
(interactive)
(org-x--headline-meeting-add-link "ACTION_ITEMS" nil))
;; timestamp shifting ;; timestamp shifting
(defun org-x--read-number-from-minibuffer (prompt &optional return-str) (defun org-x--read-number-from-minibuffer (prompt &optional return-str)