Skip to content

Latest commit

 

History

History
68 lines (57 loc) · 2.17 KB

0017-cl-org-mode.org

File metadata and controls

68 lines (57 loc) · 2.17 KB

cl-org-mode

This library contains a parser for Emacs org-mode and a primitive tool for doing Literate Programming. If you are looking for better CL support for literate programming try :literate-lisp.

This parser can be interesting for people, who want to process org-mode files from the Common Lisp. For example, you can use it to write a plugin for blogging software like :coleslaw.

cl-org-mode has no any exported functions, but you can read it’s sources and documentation:

git clone https://gitlab.common-lisp.net/cl-org-mode/cl-org-mode.git

Here is a short example, showing how to parse one of the articles of #poftheday and extract a code snipped:

POFTHEDAY> (cl-org-mode::read-org-file "2020-03/0001-rate-monotonic.org")
#<CL-ORG-MODE::ORG-FILE {10030B4153}>
POFTHEDAY> (cl-org-mode::node.next-node *)
#<CL-ORG-MODE::OUTLINE-NODE {10030B65D3}>
POFTHEDAY> (cl-org-mode::node.heading *)
"rate-monotonic :threads:"
POFTHEDAY> (cl-org-mode::node.next-node **)
#<CL-ORG-MODE::TEXT-NODE {100317E1D3}>
POFTHEDAY> (cl-org-mode::node.next-node *)
#<CL-ORG-MODE::SRC-NODE {100317C9F3}>
POFTHEDAY> (cl-org-mode::node.text *)
"
POFTHEDAY> (let ((started-at (get-internal-real-time)))
             (dotimes (i 11)
               (format t \"i: ~A time: ~A~%\"
                       i
                       (coerce (/ (- (get-internal-real-time)
                                      started-at)
                                    internal-time-units-per-second)
                               'float))
               (force-output)
               ;; Here we are modelling a payload
               ;; which takes some time
               (sleep (random 0.1))
               ;; And here we'll try to add a sleep between
               ;; executions
               (sleep 0.1)))
i: 0 time: 0.0
i: 1 time: 0.166
i: 2 time: 0.323
i: 3 time: 0.431
i: 4 time: 0.624
i: 5 time: 0.776
i: 6 time: 0.95
i: 7 time: 1.142
i: 8 time: 1.286
i: 9 time: 1.46
i: 10 time: 1.616
"

I’m planning to write a simple static site generator for the Project of the Day, using this library and :spinneret for HTML generation.