aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarty hiatt <martianhiatus [a t] riseup [d o t] net>2023-05-05 09:25:32 +0200
committermarty hiatt <martianhiatus [a t] riseup [d o t] net>2023-05-05 09:25:32 +0200
commitdce3b60783c02605ad7961f56bf41dd6bc91b51d (patch)
tree56c33f9f522a162a3dbe9205cec4955fb77801ae
parentceee243b82c01b6c1b42cf1a703b7aeae455c713 (diff)
flyspell ignore compose buffer items
-rw-r--r--lisp/mastodon-toot.el18
1 files changed, 18 insertions, 0 deletions
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el
index dd54ac2..f7441c6 100644
--- a/lisp/mastodon-toot.el
+++ b/lisp/mastodon-toot.el
@@ -1753,6 +1753,24 @@ EDIT means we are editing an existing toot, not composing a new one."
(when initial-text
(insert initial-text))))
+;; flyspell ignore masto toot regexes:
+(defvar flyspell-generic-check-word-predicate)
+(defun mastodon-toot-mode-flyspell-verify ()
+ "A predicate function for `flyspell'.
+Only text that is not one of these faces will be spell-checked."
+ (let ((faces '(mastodon-display-name-face
+ mastodon-toot-docs-face font-lock-comment-face
+ success link)))
+ (unless (eql (point) (point-min))
+ ;; (point) is next char after the word. Must check one char before.
+ (let ((f (get-text-property (1- (point)) 'face)))
+ (not (memq f faces))))))
+
+(add-hook 'mastodon-toot-mode-hook
+ (lambda ()
+ (setq flyspell-generic-check-word-predicate
+ 'mastodon-toot-mode-flyspell-verify)))
+
;;;###autoload
(add-hook 'mastodon-toot-mode-hook
#'mastodon-profile--fetch-server-account-settings-maybe)