From cfcc3465932e4669eddcfc55adcca81f5d6561bb Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Thu, 2 May 2019 10:52:07 -0400 Subject: [PATCH] feat: Add org-clubhouse-update-labels Add a command to update the labels of an existing story from the labels of an org headline --- org-clubhouse.el | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/org-clubhouse.el b/org-clubhouse.el index 2547e136c..5d5b78f35 100644 --- a/org-clubhouse.el +++ b/org-clubhouse.el @@ -297,12 +297,13 @@ If set to nil, will never create stories with labels") "Return the Clubhouse labels based on the tags of ELT and the user's config." (unless (eq nil org-clubhouse-create-stories-with-labels) (let ((tags (org-get-tags (plist-get elt :contents-begin)))) - (cl-case org-clubhouse-create-stories-with-labels - ('t tags) - ('existing (-filter (lambda (tag) (-some (lambda (l) - (string-equal tag (cdr l))) - (org-clubhouse-labels))) - tags)))))) + (-map (lambda (l) `((name . ,l))) + (cl-case org-clubhouse-create-stories-with-labels + ('t tags) + ('existing (-filter (lambda (tag) (-some (lambda (l) + (string-equal tag (cdr l))) + (org-clubhouse-labels))) + tags))))))) ;;; ;;; API integration @@ -709,9 +710,7 @@ If the stories already have a CLUBHOUSE-ID, they are filtered and ignored." (save-mark-and-excursion (goto-char (plist-get elt :begin)) (org-clubhouse-find-description-drawer))) - (labels (-map (lambda (l) `((name . ,l))) - (org-clubhouse--labels-for-elt - elt))) + (labels (org-clubhouse--labels-for-elt elt)) (story (org-clubhouse-create-story-internal title :project-id project-id @@ -924,6 +923,23 @@ contents of a drawer inside the element called DESCRIPTION, if any." :description new-description) (message "Successfully updated story description")))) +(defun org-clubhouse-update-labels () + "Update the labels of the Clubhouse story linked to the current element. + +Will use the value of `org-clubhouse-create-stories-with-labels' to determine +which labels to set." + (interactive) + (when-let* ((elt (org-element-find-headline)) + (new-labels (org-clubhouse--labels-for-elt elt))) + (and + (org-clubhouse-update-story-at-point + :labels new-labels) + (message "Successfully updated story labels to :%s:" + (->> new-labels + (-map #'cdar) + (s-join ":")))))) + + ;;; ;;; Creating headlines from existing stories ;;;