The video opens with a regular Haskell
source file in haskell-mode
. We start off by adding headings that
break the file into meaningful chunks. A section heading is indicated
by an asterisk following Haskell single-line comment characters,
i.e. -- *
. These are top-level headings, sub-headings are indicated
by adding more asterisks.
These section markers are given meaning by
outshine. With speed commands
enabled, we can navigate between headings or edit document structure
with single keypresses, such as n
and p
to move to the "next" or
"previous" headings.
A bit of Haskell code writing is also shown to demonstrate that this is still a regular Haskell source file that ghc-mod can work with. A simple demonstration of case splitting an identifier is shown.
The structure editing capabilities of outshine are then shown with the
U
and D
keys to quickly manipulate the source file structure by
moving sections "Up" and "Down".
The next main chunk of editing shows how to focus on editing the
comments included in the source file. Here, we use outorg
to switch
to an org-mode view of the original source file by pressing
M-# #
. Org-mode lets us add LaTeX equations (which we can enter
relatively quickly using an org-mode quick template triggered by
hitting TAB
with the cursor after <eq
). After saving the outorg
edit buffer (with C-x C-s
, as usual), we can preview LaTeX snippets
with org-preview-latex-fragment
(C-c C-x C-l
). Generating these
previews takes a moment, but they are cached, so subsequent previews
are quicker.
We then include a diagram generated with the
diagrams package. The
diagram is defined in an org-babel Haskell source block (a template
triggered by hitting TAB
with the cursor after <s
helps with
creating these source blocks) so we get natural Haskell syntax
highlighting. We will use the
diagrams-builder
program to execute our diagram definition, but that program needs its
input as a file. We save the diagram definition to the file dia.txt
by "tangling" this block with org-babel-tangle
(C-c C-v t
).
We invoke diagrams-builder-rasterific
with a bit of shell script,
and can then view the generated PNG image directly in the document
with org-toggle-inline-images
(C-c C-x C-v
). Diagram generation
takes a few seconds, but these too are cached, so subsequent views of
the document are quick.
When done, hitting M-#
takes us back to haskell-mode with our
changes copied over as comments. A complication is that the original
source code is kept in org-babel haskell blocks when viewing the
source file with outorg. When going back to haskell-mode, the source
blocks become uncommented code, while the plain text of the org
document become comments. If we leave our diagram definition as an
org-babel haskell block, then it will be included as real source code
in our original file. This is not what we want, so we leave that block
as an org-babel block in the org
language so that it is included in
our source file as a comment. If we want syntax highlighting when
viewing the file in org-mode again, we can simply change the language
back from org
to haskell
.
The video was made with my .emacs file. It uses versions of outorg and outshine that are under my account on github, but not yet merged upstream.
Looks great. It’s very similar to lentic mode though.
http://www.russet.org.uk/blog/3035
https://github.com/phillord/lentic