forked from redguardtoo/emacs.d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit-spelling.el
85 lines (78 loc) · 3.16 KB
/
init-spelling.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
;; flyspell set up for web-mode
(defun web-mode-flyspell-verify ()
(let ((f (get-text-property (- (point) 1) 'face))
rlt)
(cond
((not (memq f '(web-mode-html-attr-value-face
web-mode-html-tag-face
web-mode-html-attr-name-face
web-mode-constant-face
web-mode-doctype-face
web-mode-keyword-face
web-mode-comment-face ;; focus on get html label right
web-mode-function-name-face
web-mode-variable-name-face
web-mode-css-property-name-face
web-mode-css-selector-face
web-mode-css-color-face
web-mode-type-face
web-mode-block-control-face
)
))
(setq rlt t))
((memq f '(web-mode-html-attr-value-face))
(save-excursion
(search-backward-regexp "=['\"]" (line-beginning-position) t)
(backward-char)
(setq rlt (string= (thing-at-point 'word) "value"))
))
(t t))
rlt
))
(put 'web-mode 'flyspell-mode-predicate 'web-mode-flyspell-verify)
(require 'flyspell-lazy)
(flyspell-lazy-mode 1)
;; better performance
(setq flyspell-issue-message-flag nil)
;; if (aspell installed) { use aspell}
;; else if (hunspell installed) { use hunspell }
;; whatever spell checker I use, I always use English dictionary
;; I prefer use aspell because:
;; 1. aspell is older
;; 2. looks Kevin Atkinson still get some road map for aspell:
;; @see http://lists.gnu.org/archive/html/aspell-announce/2011-09/msg00000.html
(if (executable-find "aspell")
(setq ispell-program-name "aspell"
;; force the English dictionary, support Camel Case spelling check (tested with aspell 0.6)
ispell-extra-args '("--sug-mode=ultra" "--lang=en_US" "--run-together" "--run-together-limit=5" "--run-together-min=2"))
(if (executable-find "hunspell")
(setq ispell-program-name "hunspell"
ispell-extra-args '("-D en_US")
)))
;;----------------------------------------------------------------------------
;; Add spell-checking in comments for all programming language modes
;;----------------------------------------------------------------------------
(dolist (hook '(lisp-mode-hook
emacs-lisp-mode-hook
scheme-mode-hook
clojure-mode-hook
ruby-mode-hook
yaml-mode
python-mode-hook
shell-mode-hook
php-mode-hook
css-mode-hook
haskell-mode-hook
caml-mode-hook
c++-mode-hook
c-mode-hook
lua-mode-hook
crontab-mode-hook
perl-mode-hook
tcl-mode-hook
js2-mode-hook))
(add-hook hook 'flyspell-prog-mode))
;; you can also use "M-x ispell-word" or hotkey "M-$". It pop up a multiple choice
;; @see http://frequal.com/Perspectives/EmacsTip03-FlyspellAutoCorrectWord.html
(global-set-key (kbd "C-c s") 'flyspell-auto-correct-word)
(provide 'init-spelling)