Skip to content

Commit

Permalink
Add buffer local safe function for disabled rules
Browse files Browse the repository at this point in the history
Merge #20
  • Loading branch information
PillFall committed Jun 8, 2023
2 parents 064c843 + a49a7ac commit 09a750c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions languagetool-core.el
Expand Up @@ -160,6 +160,7 @@ Each element is a cons-cell with the form (CODE . NAME)."
"LanguageTool buffer local disabled rules."
:group 'languagetool
:local t
:safe #'languagetool-core-safe-rules
:type '(choice
(const nil)
(repeat string)))
Expand Down Expand Up @@ -205,6 +206,15 @@ A example hint function:
"Return non-nil if LANG is safe to use."
(assoc lang languagetool-core-languages))

(defun languagetool-core-safe-rules (rules)
"Return non-nil if RULES is safe to use.
To be valid, RULES must be a list of strings form of \"UPPER_UNDERSCORE\"."
(and (listp rules)
(seq-every-p (lambda (rule)
(and (stringp rule)
(string-match-p "^[A-Z_]+$" rule)))
rules)))

(defun languagetool-core-clear-buffer ()
"Deletes all buffer overlays."
(save-restriction
Expand Down

0 comments on commit 09a750c

Please sign in to comment.