Emacs for creative writing

For those of you that are totally new to Emacs I would recommend reading Woodnotes Guide to Emacs for Writers as well as his cheatsheet.

To plan your writing and keep notes of ideas I suggest using org-mode.org. In the beginning it’s very easy to learn, but it grows together with your need to a full publishing machine that can help you writing your book which you can export in HTML, PDF, Latex and even to MS Word and LibreOffice (see http://vimeo.com/31564708).

To get better and practice more often tasks and writing games are a good idea such as “Give me a word and I write 15 minutes what comes to my mind” and if you dont keep up writing Emacs will automatically start deleting the last words. This is what Write or die! mode is for.

Now that you’ve written something Emacs can (to some degree) tell you how “good” e.g. complicated style your text is – like this sentence – by performing the Flesch-Kincaid scoring on it implemented by the writegood-mode

Another barometer for good writing style is the usage of weasel words als well as telling something in passive voice. artbollocks-mode can help you to avoid this (at least if you’re writing in English or are willing to modify the variables weasel-words-regex and passive-voice-regex).

Latex – quick & beautiful

Beside the latest Git source of auctex (due to compatibility issues with the installed version of texlive on Fedora 20, Debian Jessie and Arch Linux) I use the external packages auto-complete, ac-math, yasnippet and tex-smart-umlauts. The last one automatically converts German umlauts to the format \”a and vice versa. You always see and type umlaut character and Emacs does the rest for you.

Additionally I use yasnippets and auto-completion mode thus I am lazy and want to write as quick as my mind flows.

For spell checking flyspell and hunspell via ispell.el jumps in just because hunspell (from Libreoffice) is the most advanced spell checker available on GNU/Linux.

Last but not least I like the preview feature from auctex. It get’s you a WYSIWYG editor for Latex and by pressing C-c you can compile the current file and view it in an external program like Adobe Acrobat reader.

Here’s my complete config for copy & paste

(add-to-list 'load-path "~/.emacs.d/extensions/auctex")
(add-to-list 'load-path "~/.emacs.d/extensions/ac-math")
(load "~/.emacs.d/extensions/auctex/tex-site.el" nil t t)
(require 'reftex)
(require 'preview-latex)

(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq-default TeX-electric-escapy t)
(setq reftex-plug-into-AUCTeX t)
(setq TeX-PDF-mode t)
(setq TeX-show-compilation nil)
(setq TeX-toggle-debug-boxes nil)
(setq file_line_error_style t)
(setq TeX-view-program-list '(("Acrobat" "acroread %o")))
(setq TeX-view-program-selection '((output-pdf "Acrobat")))

(add-hook 'LaTeX-mode-hook 'visual-line-mode)
(add-hook 'LaTeX-mode-hook 'flyspell-mode)
(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)

; snippets
(require 'yasnippet)

; auto-completion
(require 'ac-math)
(add-to-list 'ac-modes 'LaTeX-mode)
(add-to-list 'ac-modes 'latex-mode)

(defun ac-LaTeX-mode-setup () ; add ac-sources to default ac-sources
(setq ac-sources
(append '(ac-source-math-unicode ac-source-math-latex ac-source-latex-commands ac-source-yasnippet)
(add-hook 'LaTeX-mode-hook 'ac-LaTeX-mode-setup)

;; Make RefTeX faster
(setq reftex-enable-partial-scans t)
(setq reftex-save-parse-info t)
(setq reftex-use-multiple-selection-buffers t)

(require 'tex-smart-umlauts)
(add-hook 'LaTeX-mode-hook #'tex-smart-umlauts-decode)

(setq latex-mode-hook
'(lambda ()
(setq ac-delay 0.2)
(define-key LaTeX-mode-map "\C-cu" 'LaTeX-find-matching-begin)
(define-key LaTeX-mode-map "\C-cd" 'LaTeX-find-matching-end)
(define-key LaTeX-mode-map "\C-ci" 'LaTeX-insert-item)

; spell checking
(require 'ispell)

(setq ispell-dictionary-base-alist
"[a-zäöüßA-ZÄÖÜ]" "[^a-zäöüßA-ZÄÖÜ]" "[']" nil
("-d" "de_DE" "-i" "iso-8859-1") nil iso-8859-1)

"[a-zA-Z]" "[^a-zA-Z]" "[']" nil
("-d" "en_US" "-i" "iso-8859-1") nil iso-8859-1)

"[a-zA-Z]" "[^a-zA-Z]" "[']" nil
("-d" "en_GB" "-i" "iso-8859-1") nil iso-8859-1)


(eval-after-load "ispell"
(setq ispell-dictionary "de_DE")
;(setq ispell-extra-args '("-t")) ; input is tex or latex
(setq ispell-silently-savep t) ; save personal dict without confirmation

(setq-default ispell-program-name "hunspell")
(setq ispell-really-hunspell t)

And here’s a tiny cheat sheet (not complete but the most usable keybindings)

C-c C-s insert section with label
C-c C-e insert new environment
C-u C-c C-e change current environment
C-c u jump to begin block
C-c d jump to end block
C-c * mark current section
C-c . mark current environment
C-c i insert \item
C-c < insert \index
C-c C-f C-b font bold
C-c C-f C-i font italics
C-c C-l show compiler output
C-c C-r compile region
C-c ` goto error
C-c ( insert a label
C-c ) list all labels and make ref entry
C-c = show toc to navigation
C-c return insert macro
M-x reftex-change-label globally rename a label
M-x reftex-goto-label goto label definition
M-x reftex-search-document Grep a label through all files