diff options
author | Griffin Smith <root@gws.fyi> | 2020-05-08T16·09-0400 |
---|---|---|
committer | Griffin Smith <root@gws.fyi> | 2020-05-08T16·09-0400 |
commit | 24be24077c8c4e12b043fb8d927d699b41264ec9 (patch) | |
tree | de7f97fe898c7a303f5293a3d79fb29251904c4a /org-clubhouse.el | |
parent | 188af3a0d3b661a12e3b854253d112e9f9044714 (diff) |
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.
Diffstat (limited to 'org-clubhouse.el')
-rw-r--r-- | org-clubhouse.el | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/org-clubhouse.el b/org-clubhouse.el index 1894f344ef42..072899ecd96e 100644 --- a/org-clubhouse.el +++ b/org-clubhouse.el @@ -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" (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. When called interactively, prompt for an epic and set the story of the clubhouse -story at point" - (interactive) +stor{y,ies} at point or region" + (interactive + (when (use-region-p) + (list nil nil nil + :beg (region-beginning) + :end (region-end)))) (if (and story-id epic-id) (progn (org-clubhouse-update-story-internal story-id :epic-id epic-id) (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 (lambda (epic-id) - (org-clubhouse-set-epic - story-id epic-id - (lambda () - (org-set-property - "clubhouse-epic" - (org-link-make-string - (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)))))))) + (-map + (lambda (elt) + (let ((story-id (org-element-extract-clubhouse-id elt))) + (org-clubhouse-set-epic + story-id epic-id + (lambda () + (org-set-property + "clubhouse-epic" + (org-link-make-string + (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))))) ;;; |