about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGriffin Smith <root@gws.fyi>2019-05-02T14·52-0400
committerGriffin Smith <root@gws.fyi>2019-05-02T14·52-0400
commitcfcc3465932e4669eddcfc55adcca81f5d6561bb (patch)
tree9240a18d90f9c0e686fff156559454409a60bc5e
parentf88deb2a331a071de6e7d83d6f9752ffd5b5a2aa (diff)
feat: Add org-clubhouse-update-labels
Add a command to update the labels of an existing story from the labels
of an org headline
-rw-r--r--org-clubhouse.el34
1 files changed, 25 insertions, 9 deletions
diff --git a/org-clubhouse.el b/org-clubhouse.el
index 2547e136ca04..5d5b78f356bf 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
 ;;;