Add spell check support to markdown files and text files
This commit is contained in:
parent
c11c8a0dd7
commit
44ab9c9e3c
|
@ -1,4 +1,4 @@
|
|||
(use-package auto-dictionary
|
||||
:defer t
|
||||
:config
|
||||
:init
|
||||
(add-hook 'flyspell-mode-hook '(lambda () (auto-dictionary-mode 1))))
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
(use-package flyspell
|
||||
:defer t
|
||||
:init
|
||||
(progn
|
||||
(add-hook 'markdown-mode-hook '(lambda () (flyspell-mode 1)))
|
||||
(add-hook 'text-mode-hook '(lambda () (flyspell-mode 1)))))
|
54
my-funcs.el
54
my-funcs.el
|
@ -220,4 +220,58 @@ argument takes the kindows rotate backwards."
|
|||
(delete-windows-on buf)
|
||||
(message "compilation ok."))))
|
||||
|
||||
;; from https://gist.github.com/cofi/3013327
|
||||
(defun cofi/helm-flyspell-correct ()
|
||||
"Use helm for flyspell correction.
|
||||
Adapted from `flyspell-correct-word-before-point'."
|
||||
(interactive)
|
||||
;; use the correct dictionary
|
||||
(flyspell-accept-buffer-local-defs)
|
||||
(let ((cursor-location (point))
|
||||
(word (flyspell-get-word))
|
||||
(opoint (point)))
|
||||
(if (consp word)
|
||||
(let ((start (car (cdr word)))
|
||||
(end (car (cdr (cdr word))))
|
||||
(word (car word))
|
||||
poss ispell-filter)
|
||||
;; now check spelling of word.
|
||||
(ispell-send-string "%\n") ;put in verbose mode
|
||||
(ispell-send-string (concat "^" word "\n"))
|
||||
;; wait until ispell has processed word
|
||||
(while (progn
|
||||
(accept-process-output ispell-process)
|
||||
(not (string= "" (car ispell-filter)))))
|
||||
;; Remove leading empty element
|
||||
(setq ispell-filter (cdr ispell-filter))
|
||||
;; ispell process should return something after word is sent.
|
||||
;; Tag word as valid (i.e., skip) otherwise
|
||||
(or ispell-filter
|
||||
(setq ispell-filter '(*)))
|
||||
(if (consp ispell-filter)
|
||||
(setq poss (ispell-parse-output (car ispell-filter))))
|
||||
(cond
|
||||
((or (eq poss t) (stringp poss))
|
||||
;; don't correct word
|
||||
t)
|
||||
((null poss)
|
||||
;; ispell error
|
||||
(error "Ispell: error in Ispell process"))
|
||||
(t
|
||||
;; The word is incorrect, we have to propose a replacement.
|
||||
(flyspell-do-correct (helm-comp-read "Correction: "
|
||||
(append
|
||||
(third poss)
|
||||
'(("Save word" . save)
|
||||
("Accept (session)" . session)
|
||||
("Accept (buffer)" . buffer)))
|
||||
:name (format "%s [%s]" word (or ispell-local-dictionary
|
||||
ispell-dictionary
|
||||
"Default"))
|
||||
:must-match t
|
||||
:alistp t)
|
||||
|
||||
poss word cursor-location start end opoint)))
|
||||
(ispell-pdict-save t)))))
|
||||
|
||||
(provide 'my-funcs)
|
||||
|
|
|
@ -193,6 +193,10 @@
|
|||
;; show -----------------------------------------------------------------------
|
||||
(evil-leader/set-key "sk" 'helm-show-kill-ring)
|
||||
(evil-leader/set-key "sr" 'evil-show-registers)
|
||||
;; spell check ---------------------------------------------------------------
|
||||
(evil-leader/set-key "sc" 'cofi/helm-flyspell-correct)
|
||||
(evil-leader/set-key "sd" 'adict-change-dictionary)
|
||||
(evil-leader/set-key "sn" 'flyspell-goto-next-error)
|
||||
;; toggle ---------------------------------------------------------------------
|
||||
(evil-leader/set-key "t8" 'toggle-fill-column-indicator)
|
||||
(evil-leader/set-key "ta" 'auto-complete-mode)
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
flx-ido
|
||||
flycheck
|
||||
flycheck-color-mode-line
|
||||
flyspell
|
||||
fringe-helper
|
||||
;; to be deleted
|
||||
;; fuzzy
|
||||
|
|
Loading…
Reference in New Issue