Org Capture Anywhere (oca
) allows you to use Org Capture for capturing items
anywhere.
Many times I need to capture structured text items that have to go in places that are not Org mode files. For example, to create tasks in Jira or Trello or adding an event on Google Calendar. This package provides simple functions to extend Org Capture’s final destination.
Once installed, call oca-setup
for setting up capture hooks. Then define your
capture workflow by writing a template and specifying a push function. The push
function takes AST of captured Org item via org-element
API and does whatever it
wants with it.
Here is an example to log lines in an SQLite database. We first define a push function that takes a headline entry and pushes the title to our database.
(defun oca-push-my-db (element)
(let ((text (org-element-property :raw-value element)))
(call-process "sqlite3" nil nil nil
"db.sqlite3" (format "insert into data (line) values (\"%s\")" text))))
Then write a capture template using oca-visit
and the push function defined
above.
(setq org-capture-templates
'(("s" "Capture to SQLite" entry (function (lambda () (oca-visit #'oca-push-my-db)))
"* %?")))
Now capturing items using C-c c s
will put the line in the database.