From 24be24077c8c4e12b043fb8d927d699b41264ec9 Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Fri, 8 May 2020 12:09:54 -0400 Subject: 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. --- org-clubhouse.el | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) (limited to 'org-clubhouse.el') 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))))) ;;; -- cgit 1.4.1