From 1d302fadc09daee556b875e8026673c97e32ba3b Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Sun, 28 Oct 2012 11:05:12 +0100 Subject: [PATCH] Add project and deadline properties * ogi.el (ogi--project): New "internal" variable. (ogi-insert-entry): Add `GH_PROJECT' property to identify which github property an entry came from. Only add a `MILESTONE' property when it has a name (as in, when it exists). Add a `DEADLINE' to the entry if the milestone has a due date. (ogi-get-for): Rename from `ogi-insert', which is kind of non-descript. Bind `ogi--project' to whichever project we're fetching so other functions can use it. --- ogi.el | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/ogi.el b/ogi.el index 637ca38..7e1452b 100644 --- a/ogi.el +++ b/ogi.el @@ -28,6 +28,9 @@ ;;; Code: +(defvar ogi--project nil + "Container for the name of the project we're fetching.") + (defun ogi-get (project) "Get a list of open issues for PROJECT." (let* ((url-request-extra-headers @@ -68,14 +71,26 @@ (replace-regexp-in-string "-" "_" (ogiprop itm name))) (ogiprop issue labels))) - (org-entry-put (point) "ID" id)))) + (org-entry-put (point) "ID" id) + (org-entry-put (point) "GH_PROJECT" ogi--project) + + (let* ((milestone (ogiprop issue milestone)) + (title (ogiprop milestone title)) + (due-on (ogiprop milestone due_on))) + (when title + (org-entry-put (point) "MILESTONE" title) + (when due-on + (message due-on) + (org-deadline + nil (replace-regexp-in-string "[TZ]" " " due-on)))))))) ;;;###autoload -(defun ogi-insert (project) +(defun ogi-get-for (project) "Insert (new) issues for PROJECT under the current entry." (interactive "MGet issues for: ") (goto-char (point-max)) - (mapc #'ogi-insert-entry (ogi-get project))) + (let ((ogi--project project)) + (mapc #'ogi-insert-entry (ogi-get project)))) (provide 'ogi)