Skip to content

Instantly share code, notes, and snippets.

@slackorama
Created August 28, 2014 21:26
Show Gist options
  • Save slackorama/1d93e8c4d9194979bcd2 to your computer and use it in GitHub Desktop.
Save slackorama/1d93e8c4d9194979bcd2 to your computer and use it in GitHub Desktop.
(defun endless/ispell-word-then-abbrev (p)
"Call `ispell-word'. Then create an abbrev for the correction made.
With prefix P, create local abbrev. Otherwise it will be global."
(interactive "P")
(let ((bef (downcase (or (car (ispell-get-word nil)) ""))) aft)
(call-interactively 'ispell-word)
(setq aft (downcase (or (thing-at-point 'word) "")))
(unless (or (string= aft bef) (string= bef ""))
(message "\"%s\" now expands to \"%s\" %sally"
bef aft (if p "loc" "glob"))
(define-abbrev
(if p local-abbrev-table global-abbrev-table)
bef aft))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment