56

This is a fork from the question What options are there for doing spell-checking in Emacs?

Because I'm currently doing a lot of non-programming tasks in Emacs I'm wondering whether Emacs can support me in writing better texts.

So, let's open with the obligatory question phrase

Are there any packages/libraries/built-ins tailored to help me write better, more correct and concise texts in Emacs?

Specifically,

  • for grammar spell check. Something similar to (but hopefully better than) the MS Word spell-checker which recognizes if a sentence is grammatically wrong

  • for improving your phrasing and the expressions you are using. Something along the lines of Dead Poets Society:

    So avoid using the word 'very' because it's lazy. A man is not very tired, he is exhausted. Don't use very sad, use morose. [...]

  • for anything which I forgot or am not aware of but you can think of (phrasing/language improvement-related, duh...)

  • “Anything which I forgot” is intrinsically too broad. “Improving your phrasing” is awfully vague, too. – Gilles Oct 14 '14 at 21:59
  • Hence I have restricted the "anything" with that part in parentheses... Also, I don't see in what possible way "improving your phrasing" could be vague inn the context of writing. – elemakil Oct 14 '14 at 22:03
  • 1
    Improving your phrasing etc. is off-topic here, I should think. There are SE sites for learning to write better. Your question should be confined to how Emacs can help you write and edit text. And that is already very broad - it could be considered too broad for a single question. Can you imagine if all of the questions about writing-help are bundled into just your one question? You would be much better off focusing on one thing at a time. And everyone else would benefit from that also. – Drew Oct 14 '14 at 22:11
  • 1
    Trad Unix had style and diction, and I am vaguely aware of an attempt to reimplement them as open source. If the tools actually work, adding an Emacs wrapper should be a snap. – tripleee Oct 15 '14 at 8:12
  • 2
    Computers cannot effectively improve your writing, at least currently. Geoffrey K. Pullum and Mark Liberman write about this a lot, for example, see itre.cis.upenn.edu/myl/languagelog/archives/005061.html or languagelog.ldc.upenn.edu/nll/?p=10416 As an example of how silly this is, I installed writegood-mode and yanked in the first paragraph of "My Old Man" (from the above link). writegood-mode identifies "my old man was cut out for a fat guy" as passive, which it is not. These systems a) do not work well and b) are based on bad rules about good writing. – Erik Hetzner Apr 6 '15 at 16:50
62

I personally stick to writing things in org-mode with flyspell-mode and langtool...

org-mode is fantastic for typing any sort of document quickly in Emacs, flyspell takes care of spelling, and langtool worries about the grammar. Everything is highly customizable too, so you can customize anything to your heart's content.

Here is a quick little type-up in org-mode with langtool and flyspell enabled; nothing too special.

If I run langtool-correct-buffer like it suggests, any grammar errors langtool found are highlighted one by one with a number of suggestions in the bottom buffer. I can select any of these candidates with the corresponding number key, or just skip over them with the [Space bar].

In addition flyspell lets me [Middle Click] on misspelled words to see spelling suggestions.

org-mode has a ton of export formats; you can export your document as a PDF, ODT, or even as HTML. (You can export using C-c C-e in org-mode)

Now that I've published my masterpiece as a PDF using LaTeX, this is what I see when I open it in a PDF viewer...

It is probably the easiest way to make fancy-looking documents within a relatively good writing environment in Emacs...

The good news is that org-mode and flyspell-mode are included by default with most versions of Emacs. The bad news is that langtool is not, and it is somewhat large, and it requires Java... But if that doesn't deter you:

Langtool is a grammar checker that is commonly paired with Openoffice or Libreoffice. The tool itself is a simple command line utility, so it is relatively easy to interface with other programs; someone interfaced it with Emacs.

To add it in Emacs, you can install it with M-x package-install langtool...Or, if you don't have the right repos set up (I use the ones suggested here.), you can get the .el file and include it manually from here.

I currently have my org-mode hook set up like this. (Snipping the irrelevant bits.)

(add-hook 'org-mode-hook (lambda ()
   (progn
     ;; Snipped
     (auto-fill-mode t)

     ;; Spelling
     (flyspell-mode t)

     ;; Grammar
     (require 'langtool)
     (setq langtool-language-tool-jar "/path/to/LanguageTool.jar"))))

Obviously, you would want to replace the /path/to/LanguageTool.jar with the actual path to it on your system. It is a portable .jar file, so the location doesn't really matter.

Also, unlike flyspell-mode, langtool requires you to run M-x langtool-check when you want to grammar check the buffer... So you don't have fancy grammar checking as you type currently.

org-mode can do a ton, and can be used to write simple little notes files, complete essays with fancy graphics, articles, books, you name it... But since it can do so much, it's kind of hard to know where to start. I found it was easiest to learn by starting with the possible ways you can export an org-mode file after you learn the basics.... Org-mode's site is very helpful and informative, and there is a lot of help on it in the info pages too (C-h i, m Org Mode).

Good luck..! And hope this helps.

  • This is great! langtool looks very promising indeed. – elemakil Oct 14 '14 at 22:39
  • 1
    Is there a way to configure langtool to be aware of (La)TeX syntax? I'd say about half of the errors are false positives caused by (La)TeX's syntax which is a bit annoying. – elemakil Oct 26 '14 at 13:10
  • 1
    Unfortunately, not to my knowledge. I usually write my stuff in plain org with very little LaTeX except for inside org LaTeX directives. (Like #+LaTeX_CLASS_OPTIONS: [hidelinks,11pt]) That way I have nothing that langtool would pick up. That's not to say a way to change where langtool doesn't exist of course, but simply that it is beyond my particular knowledge on the subject. Sorry..! – Archenoth Oct 28 '14 at 22:26
14

The EmacsWiki category Writing is the place to start.

It lists dozens of libraries that support writing text using Emacs, with one-liner descriptions and links to the detail pages.

There is no sense listing such info again here - consult it there.

(But perhaps others here will have specific recommendations.)

I will mention only the subcategory page Thesauri and Synonyms, which has more links to information about libraries that support synonym lookup.

  • Those recommendations and the personal experience with different options are what I'm mostly interested in :-) – elemakil Oct 14 '14 at 22:04
  • Fine. You should also find plenty of that on the wiki pages for this topic. – Drew Oct 14 '14 at 22:07
14

I write novels using Emacs, and have developed a workflow over time based on certain unique advantages of it. (Example: My most recent book was conceived, composed, and edited with Emacs.) That said, it is not a road without difficulties.

  • Org-mode

    Org-mode is the reason I began using Emacs. Being able to fold and unfold sections of a ~50K-words manuscript is invaluable. I previously used the program Scrivener but became disenchanted with its bloat and unplain-text .scriv files. Org-mode also has the ability to move chapters (trees and subtrees) around easily (with M-arrow_key).

  • Text Manipulation

    In addition to emacs' plethora of text-finding, slicing, and pasting utilities (C-s, M-y, etc. etc.) I use god mode and avy mode to find my way around a buffer. The modal editing enabled by the former helps with my arthritis. The latter is an extremely fast way of navigating onscreen with just a few keystrokes (usually on the home row).

  • Flyspell

    This is a perfectly adequate spell checker that benefits me every day.

  • Magit

    I recently began using Git via Bitbucket to manage my work with version control. I'm a beginner, but there are tremendous advantages, and Magit is an excellent interface to that system. Though Git isn't exactly optimized for novel writing, it works well enough.

  • TODO and COMMENT

    Org-mode has the ability to define jobs to do. With a large MS there might be 40 or more things I need to remember, from small to large. These can be identified and even ranked with TODO keywords. Also, various notes and ideas headlines can be prefaced with COMMENT, which won't export when I send the file to .odt.

  • Split window

    I often work on a file with a split window, showing two locations in a story. I frequently compare one location with another. For a long while I did this with split-window-right (C-x 3), but I've recently switched to clone-indirect-buffer-other-window (C-x 4 c). The advantage here is that if I change the folding state of window A, it does not change the folding state of window B.

  • One Disadvantage

    Literary publishing runs on MSWord. It is possible to get from .org to .doc but not, for me, easy. I presently use Emacs' org-export to port files to .odt, which I edit with Libreoffice. I manually, or with macros, achieve the formatting necessary for the larger publishing world as I know it, then save the file to .doc The formatting is not complex, but it is required.

    The editorial process involves considerable back and forth, which means that I serially export to Libreoffice and re-import to Emacs. On the Emacs end, macros can retrieve the asterisks for my headlines and straighten Word's smartquotes. I presently have no good solution for italics. Sometimes I introduce errors. If Emacs wasn't such an amazing text editing environment, I wouldn't suffer through this.

    Mickey Petersen has an excellent blog post describing his own workflow for his book Mastering Emacs, which makes use of diff buffers to sort changes and comments (beyond my ken at present), and also requires his literary editor/publisher to look at plain-text files (which I've gotten pushback on, when I've tried it).

  • Conclusion

    Emacs is the most effective tool I've found for writing and editing novels. There are also many modes that might be of use to writers of other kinds of prose (such as org2blog for composing and posting Wordpress blogs and AUCTeX for writing LaTeX files).

    I'd love to see a future where the link between .txt and .doc was smoother for the kind of writing I do. This would include:

    • setting Emacs to use double spacing or single spacing when requested
    • inserting manual page breaks (for instance, after a title page)
    • italics that don't fail around some punctuation marks
    • creating simple, right-justified headers on all pages but the title

    There are workarounds (here is a blog post by Sean Miller about getting Emacs to consistently show italics that include punctuation, which encourages use of a zero-width space), and certainly things I don't yet know how to do as someone coming from the literary rather than the programming side of the text-editing world.

Awhile ago I chanced upon a newsgroup post by rms titled "Emacs as word processor":

25 years ago I hoped we would extend Emacs to do WYSIWG word processing. That is why we added text properties and variable width fonts. However, more features are still needed to achieve this.

Could people please start working on the features that are needed?

I'd love to see a future where I could do all of my literary work in Emacs without ever having to launch another editor. I'm not there now, but nonetheless am happy overall, because the amazing utility of this editor is more than worth the extra work on the export end.

  • 1
    maybe undoc would help you? doc importer for emacs emacswiki.org/emacs/UnDoc – Jason Mirk Jul 31 '15 at 11:29
  • I'll have a look. I've used antiword before, and it was more work than it was worth, because of formatting changes that occur during extraction. Thanks for the advice! – Steven Arntson Jul 31 '15 at 16:59
11

Spin off of the original answer to the linked question.

  • Grammar Check: I am not aware of any dedicated grammar parsers for emacs yet. I will mention writegood-mode available in MELPA which highlights weasel words and passive voice in the buffer. It gets you half the way there.

    Another possibly useful library is dupwords.el which can highlight if a particular word (typically nouns and pronouns) are used more than once in the same sentence. This is more general than finding repeated adjacent words which can be handled by flyspell.

  • Anything else: Correcting language in general is a hard problem. That being said, if there exists any external program/script in this area, it is usually easy to make it interface with emacs.

If you use LaTeX for writing, I have personally found the following ruby scripts quite useful for checking style and consistency. I just call the shell command from the minibuffer itself. A viewer capable of forward and inverse search is also valuable when proofreading. On MS Windows, I use sumatra-forward package from ELPA for forward search in SumatraPDF viewer.

  1. style-check by Neil Spring
  2. hyphen-consistency by Neil Conway
0

This tip will allow you to format words / regions (bold, italics, strike through, but also parens, quotes, etc) with a single keystroke, instead of adding '/', '*', etc. at the beginning and at the end of your text. I find this useful when writing, as when re-reading and fine-tuning written texts :

(defun xa-bold (&optional char)
  (interactive)
  (unless (region-active-p)
    (backward-word)
    (mark-word))
  (if (region-active-p)
      (insert-pair 1 ?* ?*)
    (insert "//")
    (backward-char))
  (forward-word)
  (right-char))

This code is for getting a bold word/region. All you have to do is to replace the first and second ’*’ in (insert-pair 1 ?* ?*)according to what type of formatting you want. For parens, go with (insert-pair 1 ?\( ?\))

Just bind a key to it and you're done :

 (define-key org-mode-map (kbd "M-&") 'xa-bold)

Note : I felt free to add a minor change to the code I’ve stolen here. I added (forward-word) (right-char) at the end of the function because when you’re writing and want to format a word, you want point to go after the formatting character, so you can go on writing after. But you might want remove (right-char) for parens or quotes, to stay inside the paren or quote and go on writing.

I'm not a programmer, just an emacs enthousiast, playing at times with existent code. And I want emacs to become my word processor!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.