-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
handlers for org integration with elnode.
- Loading branch information
1 parent
9b4c875
commit 15f970a
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |