Talking Org Mode

Embed Size (px)

Citation preview

  • 7/31/2019 Talking Org Mode

    1/6

    1

    GranthinmBlog on Open source, Digital humanities, and Sanskrit philology

    Talking Org-modeDaniel Stender Monday, February 27th, 2012

    One of the advantages of the Emacs1 editor is that there are much great extensions

    available2. Among them, one of the true gems is definitely Org-mode (thanks Manuel

    for pointer!). The developers of Org are proud that their extension actually brought

    many people to deal with the Emacs, and thereafter to discover its ingenuity. Emacs

    high availability and expandability through Elisp is certainly of its advantages, and it

    acts like a cross-OS virtual machine for applications which have been putted on this

    Editor as a platform.

    Whats Org-mode?

    Org-mode3 (stable: 7.8.03) is a Emacs major mode which basically is a ultra versatile

    plain text outliner for taking notes. If one likes to gain an overview of Org, the huge

    capabilities are confusing at first. A reason for this is that Org is pretty much open inits scope, and people are using it for different tasks, as note taker, organizer,

    scheduler, for to-do-lists, project management, etc. etc. But in this post, I would like to

    focus mainly on Org as a publishing platform. Some features of Org are capable of

    achieving fancy things, even if Org is seen as a mere frontend to HTML or LaTeX, and

    even for your blog with Org2blog (see below).

    Radio tables within LaTeX

    A remarkable feature of Org is the build-in table editor which provides

    auto-alignment-as-you-write, easy rearrangement and also spreadsheet capabilities.

    The table mode is setted up as a minor mode (orgtbl-mode) and therefore it could be

    also employed for any non-Org documents (e.g. HTML or LaTeX source files) through

    its create-within-comment facility (radio tables)4. Tables within LaTeX are a real

    pain to create without any helpers, and orgtbl comes pretty handy for that: in a

    random LaTeX document, a radio table skeleton could be inserted through M-x

    orgtbl-insert-radio-table (a comment.styenvironment is used to wrap the source

    table). After that, activate the minor mode through M-x orgtbl-mode and start writing

    the table source within the comment environment. When its time, push C-c C-c within

    the Org table to create resp. refresh the corresponding LaTeX table isnt that justmarvellous?5

    A basic sample document would look like this:

    Granthinm - 1 / 6 - 27.04.2012

    http://www.danielstender.com/granthinam/http://www.danielstender.com/granthinam/5799/http://en.wikipedia.org/wiki/Emacshttp://en.wikipedia.org/wiki/Org-modehttp://en.wikipedia.org/wiki/Elisphttp://orgmode.org/http://orgmode.org/manual/Tables.htmlhttp://orgmode.org/manual/Radio-tables.hthttp://en.wikibooks.org/wiki/LaTeX/Tableshttp://www.ctan.org/pkg/commenthttp://www.ctan.org/pkg/commenthttp://en.wikibooks.org/wiki/LaTeX/Tableshttp://orgmode.org/manual/Radio-tables.hthttp://orgmode.org/manual/Tables.htmlhttp://orgmode.org/http://en.wikipedia.org/wiki/Elisphttp://en.wikipedia.org/wiki/Org-modehttp://en.wikipedia.org/wiki/Emacshttp://www.danielstender.com/granthinam/5799/http://www.danielstender.com/granthinam/
  • 7/31/2019 Talking Org Mode

    2/6

    2

    \documentclass{scrartcl}

    \usepackage{comment}

    \begin{document}

    Hello, world!

    % BEGIN RECEIVE ORGTBL foo\begin{tabular}{lllll}

    Monday & Tuesday & Wednesday & Thursday & Friday \\

    Rain & Rain & Rain & Rain & Rain \\

    \end{tabular}

    % END RECEIVE ORGTBL foo

    \begin{comment}

    #+ORGTBL: SEND foo orgtbl-to-latex :splice nil :skip 0

    | Monday | Tuesday | Wednesday | Thursday | Friday |

    | Rain | Rain | Rain | Rain | Rain |

    \end{comment}

    \end{document}

    Babel

    Org-mode has several outstanding features, and among them its environment for

    literate programming, Babel, could be emphazised to demonstrate Org-modes

    incredible functionality. Within an Org document, source code could be written

    directly into to literal environments or even hot-included from external files into code

    blocks. From these it could be included to and excluded from into the same document

    to do really fancy things like to hot-create diagrams for example (this is comparable to

    what Aditya Mahajan achieves with his Filter module for ConTeXt). Any code could be

    executed interactively or on-publish-time, it could be tangled (extracted) in a

    structured way into individual source code files and woven (exported) into the

    exported document in the same process. A feature likes this comes pretty useful e.g.

    when you are writing about code for a journal article, but it all goes much further like

    into reproducible research papers. Thus, even as a publishing frontend Org-mode

    develops an enormous potential.

    For a little demonstration, please check out the following setup:

    a Python source block puts out a list of 300 random integer pairs,q

    a Gnuplot code block takes them over and puts out an graph from these,q

    both code blocks get executed when the export happens,q

    the Python source is printed out,q

    while the Gnuplot source block gets replaced by the resulting image:6q

    Heres a Python script prints out a random tabular of integer pairs:

    import random

    out="| %s | %s |"

    Granthinm - 2 / 6 - 27.04.2012

    http://en.wikipedia.org/wiki/Literate_programminghttp://orgmode.org/worg/org-contrib/babel/index.htmlhttps://github.com/adityam/filterhttps://github.com/adityam/filterhttp://orgmode.org/worg/org-contrib/babel/index.htmlhttp://en.wikipedia.org/wiki/Literate_programming
  • 7/31/2019 Talking Org Mode

    3/6

    3

    for x inrange(0, 300):

    pair=(random.randrange(1000), random.randrange(1000))

    print out % pair

    An heres the resulting graph:

    By the way, here are the preceeding lines of the Org source:7

    Here's a Python script prints out a random tabular of integer pairs:

    #+srcname: foo

    #+begin_src python :results output raw :exports code

    import random

    out="| %s | %s |"

    for x in range(0, 300):

    pair=(random.randrange(1000), random.randrange(1000))

    print out % pair

    #+end_src

    An here's the resulting graph:

    #+begin_src gnuplot :var data=foo :file gnuplot.png :exports results

    reset

    set terminal png size 500,375

    plot data u 1:2 notitle

    #+end_src

    By the way, here are the preceeding lines of the Org source:[7]

    Granthinm - 3 / 6 - 27.04.2012

  • 7/31/2019 Talking Org Mode

    4/6

    4

    Org2blog

    Furthermore, I would like to point right further to the extension Org2blog, which

    provides export to WordPress directly from the running Org mode. It might not be so

    interesting to publish your checkboxed todo-lists on your blog, but when it comes to

    how elegant Org handles features like sections, links, footnotes, etc. it really makes up

    a deluxe editing frontend for WordPress, plus, of course the features which have beendiscussed here so far could be forwarded directly to your blog easily with that

    extension.

    Unfortunately, Org2blog isnt available through the package management so far (see

    here), so it must be installed manually. Basically, there are three ways to do so,

    you could clone the repositories of Org2blog (and the needed Elisp implementation of1.

    XML-RPC) somewhere into the Emacs search path 8,

    you could get the ELPA extension retrieval package.el into charge 9,2.

    and finally, you could use el-get for retrieving the add-ons

    10

    .3.

    After Org2blog has been got and proper configured 11, you can publish from the

    running Org file directly with M-x org2blog/wp-post-buffer-and-publish12. Actually,

    this post was created with Org-mode and Org2blog.

    Footnotes:

    1 The current stable release is 23.4, but Emacs 24 is just around the corner. If you

    cant wait to run one of its additional features (see here), there are unofficial snapshot

    packages available. Many stuff Ive came across (like the Emacs Starter Kit) is alreadymade up for Emacs 24.

    2 For working with Emacs of course the manual is essential. Within a running Emacs,

    press C-h t to open the build-in tutorial. The classic introduction is OReillysLearning

    GNU Emacs (currently 3rd edition), and theres also a title in Sams Teach Yourself

    series, a complete Howto from the Linux guys, and a tutorial at IBM Developer Works.

    Very brief Ive found is the tutorial at the University of Chicago Library, and very

    useful also is thePocketReference. PeepCode features a great screencast on Emacs,

    which gives a great overview even over the advanced stuff.

    3 Among the Org documentation there is a compact guide next to the much more

    detailed manual. Very useful also the the Refcard. There are several introductions,

    tutorials and screencasts available (see here), among them the talk of Carsten

    Dominik at Google Tech Talks provides a great overview of the different functions of

    Org. A fine German article could be found inDas freie Magazin 10 of 2009 (p. 18 sq.),

    and another very easy written English article could be found in theLinux Journal of

    2007. Everything within Emacs is documented out, so you just have to M-x org-info to

    reach the build-in documentation. By the way, current Pandoc features Org as output

    format.

    4 Theres a nice tutorial on Org tables, and a demonstration in Dominiks talk at

    Google Tech Talks (00:29:00 sq.), The radio table feature is demonstrated in this

    Granthinm - 4 / 6 - 27.04.2012

    https://github.com/punchagan/org2bloghttp://bugs.debian.org/cgi-bin/bugreport.cgi?bug=650576https://launchpad.net/xml-rpc-elhttps://launchpad.net/xml-rpc-elhttp://xahlee.org/emacs/emacs23_features.htmlhttp://www.masteringemacs.org/articles/2011/12/06/what-is-new-in-emacs-24-part-1/http://emacs.naquadah.org/http://emacs.naquadah.org/https://github.com/technomancy/emacs-starter-kithttp://www.gnu.org/software/emacs/manual/emacs.htmlhttp://my.safaribooksonline.com/book/operating-systems-and-server-administration/emacs/0596006489http://my.safaribooksonline.com/book/operating-systems-and-server-administration/emacs/0596006489http://www.emacs.uniyar.ac.ru/doc/em24h/http://www.emacs.uniyar.ac.ru/doc/em24h/http://www.emacs.uniyar.ac.ru/doc/em24h/http://tldp.org/HOWTO/Emacs-Beginner-HOWTO.htmlhttp://www.ibm.com/developerworks/views/aix/libraryview.jsp?search_by=emacs+editing+environmenthttp://www2.lib.uchicago.edu/keith/tcl-course/emacs-tutorial.htmlhttp://my.safaribooksonline.com/book/operating-systems-and-server-administration/emacs/1565924967http://peepcode.com/products/meet-emacshttp://orgmode.org/org-mode-documentation.htmlhttp://orgmode.org/guide/index.htmlhttp://orgmode.org/manual/index.htmlhttp://orgmode.org/org-mode-documentation.htmlhttp://orgmode.org/worg/org-tutorials/index.htmlhttp://www.youtube.com/watch?v=oJTwQvgfgMMhttp://www.youtube.com/watch?v=oJTwQvgfgMMftp://ftp.freiesmagazin.de/2009/freiesMagazin-2009-10.pdfftp://ftp.freiesmagazin.de/2009/freiesMagazin-2009-10.pdfhttp://www.linuxjournal.com/article/9116?page=0,0http://www.linuxjournal.com/article/9116?page=0,0http://www.linuxjournal.com/article/9116?page=0,0http://johnmacfarlane.net/pandochttp://orgmode.org/worg/org-tutorials/tables.htmlhttp://www.youtube.com/watch?v=EQAd41VAXWohttp://www.youtube.com/watch?v=EQAd41VAXWohttp://orgmode.org/worg/org-tutorials/tables.htmlhttp://johnmacfarlane.net/pandochttp://www.linuxjournal.com/article/9116?page=0,0http://www.linuxjournal.com/article/9116?page=0,0http://www.linuxjournal.com/article/9116?page=0,0ftp://ftp.freiesmagazin.de/2009/freiesMagazin-2009-10.pdfftp://ftp.freiesmagazin.de/2009/freiesMagazin-2009-10.pdfhttp://www.youtube.com/watch?v=oJTwQvgfgMMhttp://www.youtube.com/watch?v=oJTwQvgfgMMhttp://orgmode.org/worg/org-tutorials/index.htmlhttp://orgmode.org/org-mode-documentation.htmlhttp://orgmode.org/manual/index.htmlhttp://orgmode.org/guide/index.htmlhttp://orgmode.org/org-mode-documentation.htmlhttp://peepcode.com/products/meet-emacshttp://my.safaribooksonline.com/book/operating-systems-and-server-administration/emacs/1565924967http://www2.lib.uchicago.edu/keith/tcl-course/emacs-tutorial.htmlhttp://www.ibm.com/developerworks/views/aix/libraryview.jsp?search_by=emacs+editing+environmenthttp://tldp.org/HOWTO/Emacs-Beginner-HOWTO.htmlhttp://www.emacs.uniyar.ac.ru/doc/em24h/http://www.emacs.uniyar.ac.ru/doc/em24h/http://www.emacs.uniyar.ac.ru/doc/em24h/http://my.safaribooksonline.com/book/operating-systems-and-server-administration/emacs/0596006489http://my.safaribooksonline.com/book/operating-systems-and-server-administration/emacs/0596006489http://www.gnu.org/software/emacs/manual/emacs.htmlhttps://github.com/technomancy/emacs-starter-kithttp://emacs.naquadah.org/http://emacs.naquadah.org/http://www.masteringemacs.org/articles/2011/12/06/what-is-new-in-emacs-24-part-1/http://xahlee.org/emacs/emacs23_features.htmlhttps://launchpad.net/xml-rpc-elhttps://launchpad.net/xml-rpc-elhttp://bugs.debian.org/cgi-bin/bugreport.cgi?bug=650576https://github.com/punchagan/org2blog
  • 7/31/2019 Talking Org Mode

    5/6

    5

    screencast here for an HTML document.

    5 The table source can be placed anywhere in the same document, and this feature has

    some further options like splicing if you have your own table headers (see here). By

    the way, the same is also possible for lists.

    6 Gnuplot must be added to the default support for Elisp by altering the variable

    org-babel-load-languages in your .emacs file, please see this page here (the package of

    Gnuplot as well as gnuplot-mode must be installed). Orgs support for Gnuplot is well

    documented, see here. By the way, the Org feature Org-Plot is capable of running

    Gnuplot on any tabular data with a single preceding #+PLOT: line.

    7 Please remark that Ive hot-re-included the same document, just giving a line range.

    Ive got that idea from this blogposting here.

    8 First, save xml-rpc.el into ~/.emacs.d/, or better /usr/local/share/emacs/site-lisp/.

    A f ter tha t , c lone the G i t repos i tory o f Org2b log w i th g it c lo ne

    http://github.com/punchagan/org2blog.git into the same folder (to expand also the

    subdir, copy also /usr/share/emacs/site-lisp/subdirs.elhere). Then, both extensions

    must be activated by putting (require 'xml-rpc) and (require 'org2blog-autoloads)

    into ~/.emacs/ . When there isnt any error message when Emacs starts up it all runs

    properly. But much more convenient is of course to get them via el-get.

    9 Of course its more convenient to retrieve Elisp extensions through a build-in

    management. Actually, the add-on manager package.el, which queries the Emacs Lisp

    Package Archive (ELPA) and other repositories is going to be included into Emacs 24.

    On the ELPA package management, see this blog posting here.

    10 el-get is capable to recognize individual code repositories. It is available as a

    package for current Ubuntu, but the current stable (3.1) brings some new features

    like l ist-packages (see here) s o t h e b es t i d ea w ou ld b e t o git clone

    https://github.com/dimitri/el-get into /usr/local/share/emacs/site-lisp/ instead.

    After that, (require 'el-get) and (el-get 'sync) (for automatic inits) must be added to

    ~/.emacs/. Retrieval information (recipes) for both extensions, xml-rpc-el as well as

    org2blog, are already included, so all you have to do within Emacs is to do M-x

    el-get-install for each package to retrieve it (BTW, they go into ~/.emacs.d/el-get/)

    thats the way we like it!

    11 The contact information about your blog(s) have to be given to the variable

    org2blog/wp-blog-alist with at least url and username, and a good place would be also

    to store that into ~/.emacs/. The outline of this variable could be checked through C-h

    v org2blog/wp-blog-alist. For an example configuration, please check out the

    Org2blog README.

    1 2 O n t he s i d e o f W o r d P r e s s , R e mo t e p u b l i s h i n g : X ML -R P C i n

    wp-admin/options-writing.php must be checkboxed. There are meta tags like #+TITLE:

    and #+CATEGORY: available for your postings, please see the Org2blog README.

    This entry was posted on Monday, February 27th, 2012 at 1:00 am and is filed under

    Granthinm - 5 / 6 - 27.04.2012

    http://www.youtube.com/watch?v=EQAd41VAXWohttp://orgmode.org/manual/A-LaTeX-example.html#A-LaTeX-examplehttp://orgmode.org/manual/Radio-lists.html#Radio-listshttp://en.wikipedia.org/wiki/Gnuplothttp://orgmode.org/manual/Languages.htmlhttp://packages.debian.org/squeeze/gnuplothttp://packages.debian.org/squeeze/gnuplothttp://packages.debian.org/squeeze/gnuplot-modehttp://orgmode.org/worg/org-contrib/babel/languages/ob-doc-gnuplot.htmlhttp://orgmode.org/manual/Org_002dPlot.htmlhttp://www.pablumfication.co.uk/2012/01/15/blog-posting-with-emacs-using-org2blog/https://launchpad.net/xml-rpc-el/trunk/1.6.8/+download/xml-rpc.elhttps://github.com/technomancy/package.elhttp://tromey.com/elpa/http://tromey.com/elpa/http://www.masteringemacs.org/articles/2011/12/06/what-is-new-in-emacs-24-part-1/http://batsov.com/articles/2012/02/19/package-management-in-emacs-the-good-the-bad-and-the-ugly/https://github.com/dimitri/el-gethttp://packages.ubuntu.com/oneiric/el-gethttp://tapoueh.org/blog/2011/09/16-el-get-3.1.htmlhttp://tapoueh.org/blog/2011/09/16-el-get-3.1.htmlhttp://packages.ubuntu.com/oneiric/el-gethttps://github.com/dimitri/el-gethttp://batsov.com/articles/2012/02/19/package-management-in-emacs-the-good-the-bad-and-the-ugly/http://www.masteringemacs.org/articles/2011/12/06/what-is-new-in-emacs-24-part-1/http://tromey.com/elpa/http://tromey.com/elpa/https://github.com/technomancy/package.elhttps://launchpad.net/xml-rpc-el/trunk/1.6.8/+download/xml-rpc.elhttp://www.pablumfication.co.uk/2012/01/15/blog-posting-with-emacs-using-org2blog/http://orgmode.org/manual/Org_002dPlot.htmlhttp://orgmode.org/worg/org-contrib/babel/languages/ob-doc-gnuplot.htmlhttp://packages.debian.org/squeeze/gnuplot-modehttp://packages.debian.org/squeeze/gnuplothttp://packages.debian.org/squeeze/gnuplothttp://orgmode.org/manual/Languages.htmlhttp://en.wikipedia.org/wiki/Gnuplothttp://orgmode.org/manual/Radio-lists.html#Radio-listshttp://orgmode.org/manual/A-LaTeX-example.html#A-LaTeX-examplehttp://www.youtube.com/watch?v=EQAd41VAXWo
  • 7/31/2019 Talking Org Mode

    6/6

    6

    Editing

    You can follow any responses to this entry through the Comments (RSS) feed. You can

    leave a response, or trackbackfrom your own site.

    Granthinm - 6 / 6 - 27.04.2012

    http://www.danielstender.com/granthinam/editinghttp://www.danielstender.com/granthinam/comments/feed/http://www.danielstender.com/granthinam/5799/trackback/http://www.danielstender.com/granthinam/5799/trackback/http://www.danielstender.com/granthinam/comments/feed/http://www.danielstender.com/granthinam/editing