Skip to content

Instantly share code, notes, and snippets.

@Johniel
Created July 22, 2014 03:02
Show Gist options
  • Save Johniel/46c4507695be7c6b6a3a to your computer and use it in GitHub Desktop.
Save Johniel/46c4507695be7c6b6a3a to your computer and use it in GitHub Desktop.
タイポしすぎぃ!
;; 怒りのタイポ修正
;; http://d.hatena.ne.jp/kitokitoki/20091124/p2
(defun delete-word (arg)
"Delete characters forward until encountering the end of a word.
With argument ARG, do this that many times."
(interactive "p")
(delete-region (point) (progn (forward-word arg) (point))))
;; http://d.hatena.ne.jp/kitokitoki/20091124/p2
(defun backward-delete-word (arg)
"Delete characters backward until encountering the beginning of a word.
With argument ARG, do this that many times."
(interactive "p")
(delete-word (- arg)))
(defvar fix-word-map '(("cotu" . "cout")
("ocut" . "cout")
("dobule" . "double")
("doubel" . "double")
("doule" . "double")))
(defun fix-typo ()
(interactive)
(let* ((w (assoc (current-word) fix-word-map)))
(if w
(progn (call-interactively 'backward-delete-word 1)
(insert (cdr w)))))
(insert " "))
(global-set-key (kbd "SPC") 'fix-typo)
(provide 'typo-fix)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment