Allow org-clubhouse-set-epic on regions

Make org-clubhouse-set-epic set all selected stories to the same epic if
multiple stories are selected.
This commit is contained in:
Griffin Smith 2020-05-08 12:09:54 -04:00
parent 188af3a0d3
commit 24be24077c

View file

@ -1175,30 +1175,39 @@ Uses `org-clubhouse-state-alist'. Operates over stories from BEG to END"
(message "Successfully synchronized status of %d stories from Clubhouse" (message "Successfully synchronized status of %d stories from Clubhouse"
(length elts)))) (length elts))))
(defun org-clubhouse-set-epic (&optional story-id epic-id cb) (cl-defun org-clubhouse-set-epic (&optional story-id epic-id cb &key beg end)
"Set the epic of clubhouse story STORY-ID to EPIC-ID, then call CB. "Set the epic of clubhouse story STORY-ID to EPIC-ID, then call CB.
When called interactively, prompt for an epic and set the story of the clubhouse When called interactively, prompt for an epic and set the story of the clubhouse
story at point" stor{y,ies} at point or region"
(interactive) (interactive
(when (use-region-p)
(list nil nil nil
:beg (region-beginning)
:end (region-end))))
(if (and story-id epic-id) (if (and story-id epic-id)
(progn (progn
(org-clubhouse-update-story-internal (org-clubhouse-update-story-internal
story-id :epic-id epic-id) story-id :epic-id epic-id)
(when cb (funcall cb))) (when cb (funcall cb)))
(let ((story-id (org-element-clubhouse-id))) (let ((elts (-filter (lambda (elt) (plist-get elt :CLUBHOUSE-ID))
(org-clubhouse-collect-headlines beg end))))
(org-clubhouse-prompt-for-epic (org-clubhouse-prompt-for-epic
(lambda (epic-id) (lambda (epic-id)
(org-clubhouse-set-epic (-map
story-id epic-id (lambda (elt)
(lambda () (let ((story-id (org-element-extract-clubhouse-id elt)))
(org-set-property (org-clubhouse-set-epic
"clubhouse-epic" story-id epic-id
(org-link-make-string (lambda ()
(org-clubhouse-link-to-epic epic-id) (org-set-property
(alist-get epic-id (org-clubhouse-epics)))) "clubhouse-epic"
(message "Successfully set the epic on story %d to %d" (org-link-make-string
story-id epic-id)))))))) (org-clubhouse-link-to-epic epic-id)
(alist-get epic-id (org-clubhouse-epics))))
(message "Successfully set the epic on story %d to %d"
story-id epic-id))))))
elts)))))
;;; ;;;