Write in Emacs

1 writing a book in Emacs

I am not going to preach the powerful tool, Org. In this post, I want to write something on the tools which facilitate the literature writing. Indeed, if I am going to write a book someday (when time is not a problem), the very tool I will adopt definitely is Emacs.

With high probability, I will adopt the workflow like Mickey Petersen did. Also, Emacs has many extensions that make writing a book or an article in large size possible. In general, I will write it in Org mode, and export the book to other format with just a C-c C-e, which is a convenient shortcut memorized by my muscle.

2 Extensions that facilitate writing

2.1 Working Environment

My working Environment is listed as below:

  1. Windows 10 on Surface Pro 4;
  2. Emacs 25.0.5;
  3. Org 9.1.6;
  4. Also, I use spacemacs, a comprehensive configuration with many functions organized as layers.

2.2 Org

The Org mode, the killer extension, makes Emacs great again. I surely did quite a few customization on Org. However, I use the org layer shipped with spacemacs.

Also, you can configure Org like a word processor. Org-bullet package make Org mode beautiful. I set Org bullets as:

(setq org-bullets-bullet-list '("✿" "❀" "♣" "♧" ))

As mentioned before, you can export your Org file using several formats such as HTML,TeX, PDF, Markdown and so on.

I use Org writing my own blog through ox-hugo. Of course, I use Hugo. Why not? Hugo is fast and disk-space-friend. Hugo also has its windows distribution. ox-hugo export the org files as markdown files which are supported by hugo.

I use Org to export PDF based on the latex class defined org-article ,which is a latex class I forked from tsdye/org-article and added the support for Chinese characters. Org-article is a flexible latex class and export beautiful PDF with the good-looking fonts and architecture.

2.3 Spell Checking

Using flyspell, spell checking is easy. There is a layer named spell-checking distributed with spacemacs.

I use aspell instead of ispell. So, I set:

(setq-default ispell-program-name "C:/Aspell/bin/aspell.exe")

Of course, you have to install aspell and the dictionaries. I use the Win32 version.

Using flyspell mode, you can also insert some word into your personal dictionary.

2.4 Moving around

Using Spacemacs, moving around is easy because it has almost all the jumping shortcuts used in Vim (if you use the Vim mode in spacemacs).

On the other hand, using Org, you can jump from headline to headline easily. Promoting and demoting a headline is also fast. You can even change the head level of a headline using just a few keystrokes.

The tab key is a useful shortcut to change the face of how the Org buffer looks like. I use the tab key to give me a sketch view of the post I am working on. Furthermore, you can even use the narrow function to restrict the buffer showing only the section of subsection part you are working if your file is getting large and you don’t want to be distracted by other parts of your article.

Through the writing of this post, I also using the commands moving around sentences and paragraphs often.

Table 1: move around in Org files
commands description
h,j,k,l the basic Vim keys, need no description
0 goto the beginning of a line
$ goto the end of a line
M-a goto the beginning of a sentence
M-e goto the end of a sentence
M-k move a paragraph up when cursor stays in a paragraph
M-j move a paragraph down when cursor stays in a paragraph
M-{ goto the beginning of previous paragraph
M-} goto the beginning of next paragraph

In the Org mode, the following commands are also very convenient.

M-j org metadown when cursor stays in a headline
M-k org metaup when cursor stays in a headline
< promote a headline when cursor stays in a headline
> demote a headline when cursor stays in a headline
C-c C-f goto the next headline of the same level
C-c C-b goto the previous headline of the same level
C-c C-n goto the next headline, not necessarily the same level
C-c C-p goto the previous headline, not necessarily the same level

2.5 count words

count-words is a command built in Emacs. There is a github repository “advance words count” which helps count the CJK word. If you write in CJK language, it will be handy.

2.6 focus on current section

Three handy functions help me focus on what I am working on.

  1. the fullscreen spacemacs/toggle-fullscreen-frame which block distractions from other apps.
  2. the org-capture which allow me capture the ideas or aspirations hitting my head.
  3. the narrow function. This is extremely useful especially when your article or post have quite a lot sections. You can narrow your buffer to the very section you are working on.

3 Reference

  1. how-to-write-a-book-in-emacs
  2. Emacs for writing ? Tell me your tricks !
  3. My Emacs Writing Setup . This is an old post by Tony Ballantyne, a writer, whose blog http://tonyballantyne.com/ provides a lot of information on how to write.
  4. On irreal.org , you can always find something unexpectedly.
  5. An Absolute Beginners Guide to Spacemacs for Academic Writing . This post is a comprehensive guide for beginners using spacemacs. I learn quite a lot from it.
  6. Pandoc, the swiss-army knife for file format conversion.

Related

comments powered by Disqus