Skip to content

Instantly share code, notes, and snippets.

@cryptorick
Created December 8, 2018 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cryptorick/961abbaec109f5ddc09f22e060ec64c3 to your computer and use it in GitHub Desktop.
Save cryptorick/961abbaec109f5ddc09f22e060ec64c3 to your computer and use it in GitHub Desktop.
Make ispell work better with Org
;;; Stolen from
;;; https://github.com/grettke/help/blob/master/help.org#spell-checking
;; Make ispell work better with Org by skipping parts you don't want
;; spellchecked like code blocks and metadata. This is a standalone
;; version of this from Grant's help repo. Thanks, Grant!
(defconst help/org-special-pre "^\s*#[+]")
(defun help/block-regex (special)
"Make an ispell skip-region alist for a SPECIAL block."
(interactive)
`(,(concat help/org-special-pre "BEGIN_" special)
.
,(concat help/org-special-pre "END_" special)))
;; Source-Blocks.
(add-to-list 'ispell-skip-region-alist (help/block-regex "SRC"))
;; Example-Blocks. This system often uses Source-Blocks to edit content and Example-Blocks to make it easily renderable when it is not for running.
(add-to-list 'ispell-skip-region-alist (help/block-regex "EXAMPLE"))
;; Properties.
(add-to-list 'ispell-skip-region-alist '("^\s*:PROPERTIES\:$" . "^\s*:END\:$"))
;; Footnotes.
(add-to-list 'ispell-skip-region-alist '("\\[fn:.+:" . "\\]"))
;; Footnotes with URLs that contain line-breaks.
(add-to-list 'ispell-skip-region-alist '("^http" . "\\]"))
;; Bold text list items.
(add-to-list 'ispell-skip-region-alist '("- \\*.+" . ".*\\*: "))
;; Right arrows.
(add-to-list ' ispell-skip-region-alist '("\\rarr"))
;; Check SPECIAL LINE definitions, ignoring their type.
(let ()
(--each
'(("ATTR_LATEX" nil)
("AUTHOR" nil)
("BLOG" nil)
("CREATOR" nil)
("DATE" nil)
("DESCRIPTION" nil)
("EMAIL" nil)
("EXCLUDE_TAGS" nil)
("HTML_CONTAINER" nil)
("HTML_DOCTYPE" nil)
("HTML_HEAD" nil)
("HTML_HEAD_EXTRA" nil)
("HTML_LINK_HOME" nil)
("HTML_LINK_UP" nil)
("HTML_MATHJAX" nil)
("INFOJS_OPT" nil)
("KEYWORDS" nil)
("LANGUAGE" nil)
("LATEX_CLASS" nil)
("LATEX_CLASS_OPTIONS" nil)
("LATEX_HEADER" nil)
("LATEX_HEADER_EXTRA" nil)
("NAME" t)
("OPTIONS" t)
("POSTID" nil)
("RESULTS" t)
("SELECT_TAGS" nil)
("STARTUP" nil)
("TITLE" nil))
(add-to-list
'ispell-skip-region-alist
(let ((special (concat "#[+]" (car it) ":")))
(if (cadr it)
(cons special "$")
(list special))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment