Sunday, December 19, 2010

Finding Emacs - Orgmode, Outlines and Ascii Export

I mentioned earlier that I came to Emacs because I thought Orgmode would be a great thing to use.  Cross platform, readable format and a powerful tool once it has been learnt.  To make the learning curve a little flatter, here is how to do a simple outline in Orgmode, and to export it to a text file.

I've already pointed to the link that shows the few lines that are needed to be inserted in the " init.el " file, so all we need to do is to open a file and start.  I name all my orgmode files with the suffix " .org " - makes it easier to recognise, and Emacs will know that we want orgmode.  The first lines of an orgmode file I open are:

-*- mode:org ; mode:visual-line -*-
#+STARTUP: indent
#+OPTIONS: H:4


The lines re-confirm it is an orgmode file, and ensure the system is set up for wordwrap the way I like it.  I tell orgmode I want the headings arranged in a more readable format, and that when I export, I want down to four levels of headings (the default is three).

To start a level one heading, type something like:

* heading one

  • If you now type M-RETURN, you will get another level one heading below it ready to name.
  • Once you have your second level one heading, type M-RIGHTARROW - you now have a level two heading. Try M-LEFTARROW now.
  • Note the coloured headings - a different colour for each heading level
  • With two level one headings, experiment with M-DOWNARROW and M-UPARROW and see that the headings (and all their sub-trees) swap around
  • If you type RETURN, then you can simply start typing text.

Want to do a list?  Try this:

list header
- list item

at the end of the " - list item " line, M-RETURN and there is the next item started for you.

Exporting

Want to export as a plain, formatted text file?
Org>Export/Publish..  menu item

A new buffer appears in a split (is that a window or a frame, he thinks)  and type   "  a  " from the list of possibilities, and the export is confirmed in the mini-buffer at the bottom.  It appears as a " .txt " file in the same directory as the " .org " file you were using.

Here is what I got:


         -*- mode:org ; mode:visual-line -*-
         ========================

Author:  
Date: 2010-12-19 11:26:27



Table of Contents
=================
1 heading one
2 Another heading


1 heading one
^^^^^^^^^^^^^^

2 Another heading
^^^^^^^^^^^^^^^^^^^
list header:
- list item
-


Of course, if you want to avoid the the first line starting with -*- , there are several ways you can easily do this, but I won't go into that now.  One final note, when you export to HTML, it follows the HTML logic, so that if you have an informal list like so:

item one
item two
item three

Then they will appear in the HTML export as:

item oneitem twoitem three



later ................

Update 12 jan11:

You can comment out the first line "-*- mode:org ; mode:visual-line -*-" to be:

# -*- mode:org ; mode:visual-line -*-

and it will not appear in the export and it will still give you the presets for your file.

No comments:

Post a Comment