Refactor +markdown-flyspell-word-p predicate
A little faster and less duplicated logic.
This commit is contained in:
parent
0f3226558f
commit
7f99eb7a48
1 changed files with 24 additions and 16 deletions
|
@ -2,23 +2,31 @@
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +markdown-flyspell-word-p ()
|
(defun +markdown-flyspell-word-p ()
|
||||||
"Return t if point is on a word that should be spell checked.
|
"Return t if `flyspell' should check work before point.
|
||||||
|
|
||||||
Return nil if on a link url, markup, html, or references."
|
Used for `flyspell-generic-check-word-predicate'. Augments
|
||||||
(let ((faces (doom-enlist (get-text-property (point) 'face))))
|
`markdown-flyspell-check-word-p' to:
|
||||||
(or (and (memq 'font-lock-comment-face faces)
|
|
||||||
(memq 'markdown-code-face faces))
|
a) Do spell check in code comments and
|
||||||
(not (cl-loop with unsafe-faces = '(markdown-reference-face
|
b) Inhibit spell check in html markup"
|
||||||
markdown-url-face
|
(and (markdown-flyspell-check-word-p)
|
||||||
markdown-markup-face
|
(save-excursion
|
||||||
markdown-comment-face
|
(goto-char (1- (point)))
|
||||||
markdown-html-attr-name-face
|
(if (or
|
||||||
markdown-html-attr-value-face
|
;; Spell check in code comments
|
||||||
markdown-html-tag-name-face
|
(not (and (markdown-code-block-at-point-p)
|
||||||
markdown-code-face)
|
(markdown--face-p (point) '(font-lock-comment-face))))
|
||||||
for face in faces
|
;; Don't spell check in html markup
|
||||||
if (memq face unsafe-faces)
|
(markdown--face-p (point) '(markdown-html-attr-name-face
|
||||||
return t)))))
|
markdown-html-attr-value-face
|
||||||
|
markdown-html-tag-name-face)))
|
||||||
|
(prog1 nil
|
||||||
|
;; If flyspell overlay is put, then remove it
|
||||||
|
(when-let (bounds (bounds-of-thing-at-point 'word))
|
||||||
|
(cl-loop for ov in (overlays-in (car bounds) (cdr bounds))
|
||||||
|
when (overlay-get ov 'flyspell-overlay)
|
||||||
|
do (delete-overlay ov))))
|
||||||
|
t))))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue