FlySpell in Org-Mode recognize latex syntax like auctex

1.4k views Asked by At

Original Response: I was trying to figure out how in auctex mode latex doesn't seem to highlight any latex functions with flyspell turned on. Is this a custom dictionary file or how is this implemented? Can this be easily incorporated into an org-mode file so it doesn't highlight inserted latex code that will get exported.

Edit: Simple example taken from top of file and in the text. Basically so latex syntax like ref or label inside {} won't be spell checked (this has been fixed by using (setq ispell-parser tex). Then also setting up a function that specific labels with #+ as the first text on the line won't be checked. I would want the caption checked but not #+LABEL: or #+TYP_TODO: (not shown. Also a way to add TODO keywords to not get checked. I can think of a way to do this is on startup add these to the LOCALWORDS: ispell places at the bottom of the file if not already there but is there an easier or better way to do this.

#+TAGS: NOTE REPORT export noexport MEETING
#+TYP_TODO: TODO Weekly WAITING NEXT | Meeting DONE
#+STARTUP: hidestars content hideblocks

The exponential running mean is shown for various alpha values in Figure \ref{fig:saturation_varying_alphaval_00f6set2}.  
     #+CAPTION:    Plot of varying alpha values for the exponential running mean ($EM$) with $S_{min} = 0.0008 \text{ and } P_m = 0.20$
     #+LABEL:      fig:saturation_varying_alphaval_00f6set2
     #+ATTR_LaTeX: width=0.4\textwidth placement=[h!tb]
2

There are 2 answers

0
pmr On BEST ANSWER

flyspell internally uses ispell-mode. To change the way that ispell parses files set the variable ispell-parser to 'tex.

(add-hook 'org-mode-hook (lambda () (setq ispell-parser 'tex)))
2
legoscia On

Most likely auctex is using flyspell-mode-predicate to define what portions of the buffer shouldn't be spellchecked. (This answer shows how to do something similar for MoinMoinWiki.) org-mode already has such a function, org-mode-flyspell-verify, which apparently doesn't work properly for you... A quick look at the source suggests that org-remove-flyspell-overlays-in should be called for buffer portions containing code samples etc.

Sorry about the handwavy answer; marking this as community wiki to invite improvements.