From dce3b60783c02605ad7961f56bf41dd6bc91b51d Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Fri, 5 May 2023 09:25:32 +0200 Subject: flyspell ignore compose buffer items --- lisp/mastodon-toot.el | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'lisp/mastodon-toot.el') 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) -- cgit v1.2.3