Add editing-scrumelo-story macro
This macro makes it easier to define some actions to edit a scrumelo story and then saving that buffer.
This commit is contained in:
parent
164bd5cea3
commit
8aa9bcb7d5
1 changed files with 23 additions and 15 deletions
38
scrumelo.el
38
scrumelo.el
|
@ -14,6 +14,9 @@
|
||||||
(require 'esxml)
|
(require 'esxml)
|
||||||
(require 'org)
|
(require 'org)
|
||||||
|
|
||||||
|
(eval-when-compile
|
||||||
|
(require 'cl-macs))
|
||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
(defvar scrumelo-project-file "~/projects/scrumelo/aeos.org"
|
(defvar scrumelo-project-file "~/projects/scrumelo/aeos.org"
|
||||||
|
@ -49,6 +52,20 @@
|
||||||
"http://cdnjs.cloudflare.com/ajax/libs/react/0.3.2/JSXTransformer.js"
|
"http://cdnjs.cloudflare.com/ajax/libs/react/0.3.2/JSXTransformer.js"
|
||||||
"The location of the JSX Transformer JS file.")
|
"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)
|
(defmacro with-scrumelo-http-params (params httpcon &rest body)
|
||||||
"Bind parameters PARAMS from HTTPCON and execute BODY."
|
"Bind parameters PARAMS from HTTPCON and execute BODY."
|
||||||
(declare (indent 2))
|
(declare (indent 2))
|
||||||
|
@ -121,14 +138,10 @@
|
||||||
(elnode-method httpcon
|
(elnode-method httpcon
|
||||||
(POST
|
(POST
|
||||||
(with-scrumelo-http-params (id) httpcon
|
(with-scrumelo-http-params (id) httpcon
|
||||||
(with-scrumelo-buffer
|
(editing-scrumelo-story id
|
||||||
(let ((entry (cdr (org-id-find id))))
|
|
||||||
(goto-char entry)
|
|
||||||
(org-todo)
|
|
||||||
(save-buffer)
|
|
||||||
(scrumelo--send-json
|
(scrumelo--send-json
|
||||||
httpcon
|
httpcon `((:state . ,(org-entry-get (point) "TODO"))))
|
||||||
(list (cons :state (org-entry-get (point) "TODO"))))))))))
|
(org-todo))))))
|
||||||
|
|
||||||
(defun scrumelo-move-story (dir)
|
(defun scrumelo-move-story (dir)
|
||||||
"Create a function to move a story in direction DIR."
|
"Create a function to move a story in direction DIR."
|
||||||
|
@ -137,14 +150,9 @@
|
||||||
(elnode-method httpcon
|
(elnode-method httpcon
|
||||||
(POST
|
(POST
|
||||||
(with-scrumelo-http-params (id) httpcon
|
(with-scrumelo-http-params (id) httpcon
|
||||||
(with-scrumelo-buffer
|
(editing-scrumelo-story id
|
||||||
(let ((entry (cdr (org-id-find id))))
|
(scrumelo--send-json httpcon '((:status . "OK")))
|
||||||
(goto-char entry)
|
(funcall func))))))))
|
||||||
(funcall func)
|
|
||||||
(save-buffer)
|
|
||||||
(scrumelo--send-json
|
|
||||||
httpcon
|
|
||||||
(list (cons :status "OK")))))))))))
|
|
||||||
|
|
||||||
(defun scrumelo--send-json (httpcon obj)
|
(defun scrumelo--send-json (httpcon obj)
|
||||||
"Respond to HTTPCON with OBJ converted to a json structure."
|
"Respond to HTTPCON with OBJ converted to a json structure."
|
||||||
|
|
Loading…
Reference in a new issue