aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2013-06-22 00:05:33 +0200
committerGravatar Tom Willemse2013-06-22 00:05:33 +0200
commit8aa9bcb7d5fd80592868a6eebedc40bb0c775ef7 (patch)
tree25f0982b7bfcdab0bc0dc60502ad4a1573401f4a
parent164bd5cea3bc5c4274c6a156131307b0d0dc2ce3 (diff)
downloadscrumelo-8aa9bcb7d5fd80592868a6eebedc40bb0c775ef7.tar.gz
scrumelo-8aa9bcb7d5fd80592868a6eebedc40bb0c775ef7.zip
Add editing-scrumelo-story macro
This macro makes it easier to define some actions to edit a scrumelo story and then saving that buffer.
-rw-r--r--scrumelo.el38
1 files changed, 23 insertions, 15 deletions
diff --git a/scrumelo.el b/scrumelo.el
index 19e1439..1adf0f5 100644
--- a/scrumelo.el
+++ b/scrumelo.el
@@ -14,6 +14,9 @@
(require 'esxml)
(require 'org)
+(eval-when-compile
+ (require 'cl-macs))
+
;;; Code:
(defvar scrumelo-project-file "~/projects/scrumelo/aeos.org"
@@ -49,6 +52,20 @@
"http://cdnjs.cloudflare.com/ajax/libs/react/0.3.2/JSXTransformer.js"
"The location of the JSX Transformer JS file.")
+(defmacro editing-scrumelo-story (id after &rest body)
+ "Edit the story with ID.
+
+Goto the story with ID and execute AFTER after executing BODY and
+saving the buffer."
+ (declare (indent 2))
+ (let ((entry-var (cl-gensym)))
+ `(with-scrumelo-buffer
+ (let ((,entry-var (cdr (org-id-find ,id))))
+ (goto-char ,entry-var)
+ ,@body
+ (save-buffer)
+ ,after))))
+
(defmacro with-scrumelo-http-params (params httpcon &rest body)
"Bind parameters PARAMS from HTTPCON and execute BODY."
(declare (indent 2))
@@ -121,14 +138,10 @@
(elnode-method httpcon
(POST
(with-scrumelo-http-params (id) httpcon
- (with-scrumelo-buffer
- (let ((entry (cdr (org-id-find id))))
- (goto-char entry)
- (org-todo)
- (save-buffer)
+ (editing-scrumelo-story id
(scrumelo--send-json
- httpcon
- (list (cons :state (org-entry-get (point) "TODO"))))))))))
+ httpcon `((:state . ,(org-entry-get (point) "TODO"))))
+ (org-todo))))))
(defun scrumelo-move-story (dir)
"Create a function to move a story in direction DIR."
@@ -137,14 +150,9 @@
(elnode-method httpcon
(POST
(with-scrumelo-http-params (id) httpcon
- (with-scrumelo-buffer
- (let ((entry (cdr (org-id-find id))))
- (goto-char entry)
- (funcall func)
- (save-buffer)
- (scrumelo--send-json
- httpcon
- (list (cons :status "OK")))))))))))
+ (editing-scrumelo-story id
+ (scrumelo--send-json httpcon '((:status . "OK")))
+ (funcall func))))))))
(defun scrumelo--send-json (httpcon obj)
"Respond to HTTPCON with OBJ converted to a json structure."