41

By default, the results of running M-x ispell-buffer in org-mode are very disappointing.

  1. Ispell looks inside :PROPERTY: drawers, which commonly contain things like

    :ID:       797495bd-581b-4a42-883b-c2a55a08f08a
    
  2. It tries to correct org statements! For instance, it complains about the SRC in

    #+BEGIN_SRC emacs-lisp
    
  3. It goes inside org-blocks. I suppose this might be useful for blocks like #+BEGIN_QUOTE, but in source code blocks that’s just silly.

Is there a package that fixes all this?

I’d love to spell-check my writing but the amount of false-positives I’m getting makes it unfeasible.

If it matters, the OS's spell checker is aspell.

Malabarba
  • 22,878
  • 6
  • 78
  • 163
  • There is a flyspell predicate for org-mode (check `(get 'org-mode 'flyspell-mode-predicate)`), but I'm not sure how that could be generalised for `ispell-buffer`. – legoscia Sep 29 '14 at 13:03
  • @legoscia Ispell has a variable called `ispell-parser`, so flyspell's predicate might work well there with a wrapper around it. – Malabarba Sep 29 '14 at 13:11
  • 1
    I use flyspell and hunspell and I don't see that behavior. Anything in lines with `#+` or in source code blocks is not spell-checked. But normal text under headings is checked. I have these in my flyspell setup: `(add-hook 'prog-mode-hook 'flyspell-prog-mode)`, `(add-hook 'org-mode-hook 'turn-on-flyspell)` – Kaushal Modi Sep 29 '14 at 13:40
  • @kaushalmodi Yeah, flyspell is smarter than ispell. Unfortunately, flyspell is a little demanding for my laptops processing power :(. It's not unusable, but it's a little annoying, which is why I was trying ispell. – Malabarba Sep 29 '14 at 13:44
  • @Malabarba unfortunately `ispell-parser` appears to be just a symbol, and code all over the place checks it for particular values. So nothing really extensible. – Sigma Sep 29 '14 at 21:48
  • @Sigma Shame. I might just have to resign to using flyspell. :-( – Malabarba Sep 29 '14 at 22:28
  • @Malabarba and @Sigma: One option could be to use the `flyspell-lazy` package in addition to `flyspell` which relegates spell-checking to idle periods. I've found this significantly speeded up Org-mode file editing with flyspell on (I got some unacceptable pauses before using this package). You have to tolerate spelling errors not appearing immediately, but I've not found that a significant problem. – Stuart Hickinbottom Oct 09 '14 at 07:34
  • I was just searching for a flyspell solution myself for your point 3. The solution described [here](http://lists.gnu.org/archive/html/emacs-orgmode/2012-12/msg00764.html) works well for me, but I'm not sure how helpful it is to you. – Felix Hoffmann Oct 09 '14 at 21:25
  • 3
    Have you seen `Can I prevent ispell from checking source blocks?` in http://orgmode.org/worg/org-faq.html ? – rvf0068 Oct 10 '14 at 01:55

2 Answers2

32

As rvf0068 suggested, ispell can be configured to skip over regions that match regexes. For example, to skip over :PROPERTIES: and :LOGBOOK: drawers as well as SRC blocks, you could put this in your .emacs file:

(add-to-list 'ispell-skip-region-alist '(":\\(PROPERTIES\\|LOGBOOK\\):" . ":END:"))
(add-to-list 'ispell-skip-region-alist '("#\\+BEGIN_SRC" . "#\\+END_SRC"))

(I'm new to StackExchange, so if I've broken etiquette or rules by expanding on rvf0068's answer please let me know.)

Malabarba
  • 22,878
  • 6
  • 78
  • 163
9

If you use flyspell instead, see How does one use flyspell in org buffers without flyspell triggering on tangled code blocks?

Please note: ispell-skip-region-alist is NOT used by flyspell.

chen bin
  • 4,781
  • 18
  • 36