From 46ae9ec58d770c49f6077fda0b7d29715f9cbfb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Etienne=20Prud=E2=80=99homme?= Date: Tue, 23 May 2023 16:08:08 -0400 Subject: [PATCH 1/2] Add safe-local-variable function * languagetool-core.el: Add `languagetool-local-disabled-rules` safe-local-variable function to check that the variable is a list of strings. --- languagetool-core.el | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/languagetool-core.el b/languagetool-core.el index 0f12eda..c09bf05 100644 --- a/languagetool-core.el +++ b/languagetool-core.el @@ -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))) @@ -205,6 +206,16 @@ 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 From a49a7acf1112856871fa7f042ce7f6c1aad0b309 Mon Sep 17 00:00:00 2001 From: Joar Esteban Buitrago Carrillo Date: Wed, 7 Jun 2023 20:33:18 -0500 Subject: [PATCH 2/2] Address checkdoc comments about docstrings --- languagetool-core.el | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/languagetool-core.el b/languagetool-core.el index c09bf05..ae59c0e 100644 --- a/languagetool-core.el +++ b/languagetool-core.el @@ -208,8 +208,7 @@ A example hint function: (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\". -" +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)