summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemsen2012-10-20 18:55:46 +0200
committerGravatar Tom Willemsen2012-10-20 18:55:46 +0200
commit7fbf663ea523a0eb0f5b9e892c3b81d423828ca6 (patch)
treed414940246c45e660ff2a01ae245590b69b80bfe
parent0a9e0ee7c9b5f2e668241dbee496a13f5b062027 (diff)
downloadogi-7fbf663ea523a0eb0f5b9e892c3b81d423828ca6.tar.gz
ogi-7fbf663ea523a0eb0f5b9e892c3b81d423828ca6.zip
Extract the insert-issue function
-rw-r--r--ogi.el36
1 files changed, 19 insertions, 17 deletions
diff --git a/ogi.el b/ogi.el
index 231bab4..637ca38 100644
--- a/ogi.el
+++ b/ogi.el
@@ -52,28 +52,30 @@
"From alist OBJ get the value of PROP."
`(cdr (assq ',prop ,obj)))
+(defun ogi-insert-entry (issue)
+ "Insert a single issue into the current buffer, unless it exists."
+ (let ((id (number-to-string (ogiprop issue id))))
+ (unless (org-find-entry-with-id id)
+ (org-insert-heading-after-current)
+ (insert (ogiprop issue title))
+ (newline)
+ (insert (ogiprop issue body))
+ (fill-paragraph)
+ (org-todo (if (string= (ogiprop issue state) "closed")
+ 'done
+ "TODO"))
+ (org-set-tags-to (mapcar (lambda (itm)
+ (replace-regexp-in-string
+ "-" "_" (ogiprop itm name)))
+ (ogiprop issue labels)))
+ (org-entry-put (point) "ID" id))))
+
;;;###autoload
(defun ogi-insert (project)
"Insert (new) issues for PROJECT under the current entry."
(interactive "MGet issues for: ")
(goto-char (point-max))
- (mapc (lambda (issue)
- (let ((id (number-to-string (ogiprop issue id))))
- (unless (org-find-entry-with-id id)
- (org-insert-heading-after-current)
- (insert (ogiprop issue title))
- (newline)
- (insert (ogiprop issue body))
- (fill-paragraph)
- (org-todo (if (string= (ogiprop issue state) "closed")
- 'done
- "TODO"))
- (org-set-tags-to (mapcar (lambda (itm)
- (replace-regexp-in-string
- "-" "_" (ogiprop itm name)))
- (ogiprop issue labels)))
- (org-entry-put (point) "ID" id))))
- (ogi-get project)))
+ (mapc #'ogi-insert-entry (ogi-get project)))
(provide 'ogi)