#+TITLE: 100daystooffload day 10 #+AUTHOR: screwtape #+EMAIL: screwtape@sdf.org matto has written a wonderful primer on org-mode. Following some of [[gopher://box.matto.nl/0/org-mode-is-the-writers-secret-weapon.txt]] Note I inserted this link with C-c C-l and it opens fine in elpher-mode. Actually does this imply that I could be browsing org text files (itemtype 0s) and then switch my major mode to org and use org-mode to navigate the headings? * Writing with org-babel source/evaluation in it My brain is not in elisp mode at the moment, so let's mostly use the inferior lisp. Hopefully you have slime installed. We could have used shell or C or elisp for all of this. #+name: Initial-lisp #+begin_src elisp :results none :cache t (slime) (org-babel-do-load-languages 'org-babel-load-languages '((lisp . t))) #+end_src ** Some inline babel The day currently is call_decoded-time(field='day-of-week) {{{results(=5=)}}} This is a call_idx2weekday(idx=decoded-time(field='day-of-week)) {{{results(=SATURDAY=)}}} NB I run these by C-c C-c'ing with the cursor near the function. These calls get replaced aesthetically by their results in the export. If you evaluate these with a different argument or yourself on a different day, they will presumably be different. ** Exporting I'm a bit mystified. I guess we would often like a TeX generated pdf which is C-x C-e l p, though I don't really want a pdf. Actually I would like a text file, but I'm not sure how to get an export-style-text-file out of an org mark-down text file. It seems like I could export as html (C-x C-e h h), then ask links2 to dump its output. Basically I would like a gopher itemtype 0 export without all the visible orgmode machinery. Hints plz <3 ** There Is Much More To org-babel Okay I said much more but there are basically two more things, with far-reaching implications. There are lots of header arguments that make it easy to do lots of things [[http://orgmode.org/manual/Using-Header-Arguments.html]] Header arguments can be set/shadowed per code block, nested heading, and file (apparently these are called 'property drawers'). and then there's noweb syntax which can be turned on in the header. [[http://orgmode.org/manual/Noweb-Reference-Syntax.html]] Noweb is pretty crazy since it lets you seamlessly patchwork different language functions inside another language's source block. There's a scheme for doing it. It's also a generally powerful macro system. * Some plumbing ** Get universal time in seconds, cache. #+name: universal-time #+begin_src lisp :cache yes :eval :never-export (get-universal-time) #+end_src #+RESULTS[507f2c693f8093a0553e4e1b0a61c0579a00fac8]: universal-time : 3904409244 ** Decoded field getter getter #+name: decoded-time #+begin_src lisp :var time=universal-time() field='year :eval never-export (let ((index (search `(,field) '(second minute hour day month year day-of-week time-zone summer)))) (when index (nth-value index (decode-universal-time time)))) #+end_src ** get weekday name #+name: idx2weekday #+begin_src lisp :var idx=decoded-time(field='day-of-week) :eval never-export (nth idx '(monday tuesday wednesday thursday friday saturday sunday)) #+end_src