Skip to content

Commit

Permalink
handlers for org integration with elnode.
Browse files Browse the repository at this point in the history
  • Loading branch information
nicferrier committed Jul 23, 2012
1 parent 9b4c875 commit 15f970a
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions elnode-org.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
;;; elnode-org.el

(require 'elnode)

(defun elnode-org-update-handler (httpcon)
"Elnode handler to do org-mode updates.
Specify `file-name' for the file to update, `node-match' for an
org-agenda match, `in-node-match' to specify what will be
replaced in the node matched org line, `replace-match' for the
replacement."
(elnode-method httpcon
(POST
(let* ((file-name (elnode-http-param httpcon "file-name"))
(node-match (elnode-http-param httpcon "node-match"))
(in-node-match (elnode-http-param httpcon "in-node-match"))
(replace-match (elnode-http-param httpcon "replace-match")))
(elnode-org--update
file-name
node-match
in-node-match
replace-match)))))

(defun elnode-org--update (file-name node-match in-node-match replace-match)
"Update org-mode specified FILE-NAME.
NODE-MATCH specifies a match expression in the manner of org-agenda views.
IN-NODE-MATCH specifies a string match expression used with the
bounds of the matched node line.
REPLACE-MATCH specifies the replacement for the IN-NODE-MATCH."
(with-current-buffer (find-file-noselect file-name)
(org-map-entries
(lambda ()
(replace-regexp
in-node-match
replace-match
nil
(point)
(line-end-position)))
node-match)))

;;; enlode-org.el ends here

0 comments on commit 15f970a

Please sign in to comment.