First some disambiguation:
This Endless Parentheses page demonstrates how to use
ispell-skip-region-alist
to skip=code=
and=verbatim=
blocks with ispell…(defun endless/org-ispell () "Configure `ispell-skip-region-alist' for `org-mode'." (make-local-variable 'ispell-skip-region-alist) (add-to-list 'ispell-skip-region-alist '(org-property-drawer-re)) (add-to-list 'ispell-skip-region-alist '("~" "~")) (add-to-list 'ispell-skip-region-alist '("=" "=")) (add-to-list 'ispell-skip-region-alist '("^#\\+BEGIN_SRC" . "^#\\+END_SRC"))) (add-hook 'org-mode-hook #'endless/org-ispell)
…however,
flyspell
does not useispell-skip-region-alist
.This question on Emacs SX demonstrates how to skip flyspell checking for source blocks…
;; NO spell check for embedded snippets (defadvice org-mode-flyspell-verify (after org-mode-flyspell-verify-hack activate) (let* ((rlt ad-return-value) (begin-regexp "^[ \t]*#\\+begin_\\(src\\|html\\|latex\\|example\\|quote\\)") (end-regexp "^[ \t]*#\\+end_\\(src\\|html\\|latex\\|example\\|quote\\)") (case-fold-search t) b e) (when ad-return-value (save-excursion (setq b (re-search-backward begin-regexp nil t)) (if b (setq e (re-search-forward end-regexp nil t)))) (if (and b e (< (point) e)) (setq rlt nil))) (setq ad-return-value rlt)))
…but not for inline code and verbatim region.
How can I achieve the ispell
solution for flyspell
, where Flyspell skips any regions surrounded by ~
or =
? Generally I use these for things like variable names, which naturally tend to fail spellchecking.