In a Sweave document, code chunks in R are set off from the main text like so:
Catz are well known for their fur & pur.
<<echo = false>>=
catz <- 1 + 2
@
I'd like to run spell check for the LaTeX part (and flag "Catz") but have it skip the code chunks (not flag "catz"). In a long document, hitting "SPC" for each "misspelling" in the code section gets tedious.
Try adding this to your emacs init file:
(add-to-list 'ispell-skip-region-alist '("^<<.*>>=" . "^@"))
If Flyspell is enabled, these two additional expressions will also be needed:
(defun flyspell-eligible ()
(let ((p (point)))
(save-excursion
(cond ((re-search-backward (ispell-begin-skip-region-regexp) nil t)
(ispell-skip-region (match-string-no-properties 0))
(< (point) p))
(t)))))
(put 'latex-mode 'flyspell-mode-predicate 'flyspell-eligible)
For other modes, replace the latex-mode
in the last expression with the appropriate major mode names.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With