aboutsummaryrefslogtreecommitdiff
path: root/tests/test-chime-whitelist-blacklist-conflicts.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-05 12:39:55 -0500
committerCraig Jennings <c@cjennings.net>2026-05-05 12:39:55 -0500
commit3019a33d391912120a78cad43a49eb34c4a1d044 (patch)
tree4941d154529ce988bbdeb5e1929fa6cdea35f94a /tests/test-chime-whitelist-blacklist-conflicts.el
parent26fabb22edfea51e8a686c179ab91d00a2ff0bc3 (diff)
downloadchime-3019a33d391912120a78cad43a49eb34c4a1d044.tar.gz
chime-3019a33d391912120a78cad43a49eb34c4a1d044.zip
refactor!: collapse six filter defcustoms into include/exclude alists
Six per-axis filter variables (keyword/tags/predicate × whitelist/blacklist) were carrying parallel structure for what's really one decision: include events that look like X, exclude events that look like Y. I merged them into two alists, `chime-include-filters' and `chime-exclude-filters', each keyed by axis (`keywords', `tags', `predicates'). Default for `chime-exclude-filters' keeps the same out-of-the-box behavior — done items and declined Google Calendar invites stay filtered: ((predicates . (chime-done-keywords-predicate chime-declined-events-predicate))) Implementation: one shared `chime--filter-predicates' helper that walks the alist and emits a marker-taking predicate per non-empty axis. The public callers — now `chime--apply-include-filters' and `chime--apply-exclude-filters' — wrap that helper with `-orfn'-then-`-filter' and `-orfn'-then-`-remove' respectively. The async-environment regex injection list shrank from six names to two, and the debug config dump in chime-debug.el follows. The terminology shift (whitelist/blacklist → include/exclude) drops loaded language for descriptive intent. The internal helpers and the public function names all moved together. Tests: 700-ish lines across five test files (test-chime-apply-whitelist, test-chime-apply-blacklist, test-chime-whitelist-blacklist-conflicts, test-chime-environment-regex, test-chime-declined-events-predicate) were rewritten to bind the new alists. The dedup-conflict tests still exercise the same precedence rule (exclude wins on overlap). README's filtering section was rewritten end-to-end with new examples. Migration: (setq chime-keyword-whitelist '("TODO")) ;; -> (setq chime-include-filters '((keywords . ("TODO")))) (setq chime-predicate-blacklist '(my-pred)) ;; -> (setq chime-exclude-filters '((predicates . (my-pred)))) This brings the consolidation pass to 37 -> 29 defcustoms, the target from .ai/settings-consolidation.org.
Diffstat (limited to 'tests/test-chime-whitelist-blacklist-conflicts.el')
-rw-r--r--tests/test-chime-whitelist-blacklist-conflicts.el64
1 files changed, 28 insertions, 36 deletions
diff --git a/tests/test-chime-whitelist-blacklist-conflicts.el b/tests/test-chime-whitelist-blacklist-conflicts.el
index f79bffd..5becfe0 100644
--- a/tests/test-chime-whitelist-blacklist-conflicts.el
+++ b/tests/test-chime-whitelist-blacklist-conflicts.el
@@ -39,22 +39,14 @@
"Setup function run before each test."
(chime-create-test-base-dir)
;; Reset all whitelist/blacklist settings
- (setq chime-keyword-whitelist nil)
- (setq chime-tags-whitelist nil)
- (setq chime-predicate-whitelist nil)
- (setq chime-keyword-blacklist nil)
- (setq chime-tags-blacklist nil)
- (setq chime-predicate-blacklist nil))
+ (setq chime-include-filters nil)
+ (setq chime-exclude-filters nil))
(defun test-chime-conflicts-teardown ()
"Teardown function run after each test."
(chime-delete-test-base-dir)
- (setq chime-keyword-whitelist nil)
- (setq chime-tags-whitelist nil)
- (setq chime-predicate-whitelist nil)
- (setq chime-keyword-blacklist nil)
- (setq chime-tags-blacklist nil)
- (setq chime-predicate-blacklist nil))
+ (setq chime-include-filters nil)
+ (setq chime-exclude-filters nil))
;;; Keyword Conflict Tests
@@ -74,11 +66,11 @@ Current behavior: blacklist wins (item is filtered out)."
(let ((marker2 (point-marker)))
(forward-line 1)
(let ((marker3 (point-marker))
- (chime-keyword-whitelist '("TODO" "DONE"))
- (chime-keyword-blacklist '("DONE"))) ; DONE in both lists
+ (chime-include-filters `((keywords . ,'("TODO" "DONE"))))
+ (chime-exclude-filters `((keywords . ,'("DONE"))))) ; DONE in both lists
;; Apply both filters (simulating what happens in chime--gather-timestamps)
- (let* ((after-whitelist (chime--apply-whitelist (list marker1 marker2 marker3)))
- (after-blacklist (chime--apply-blacklist after-whitelist)))
+ (let* ((after-whitelist (chime--apply-include-filters (list marker1 marker2 marker3)))
+ (after-blacklist (chime--apply-exclude-filters after-whitelist)))
;; Whitelist should keep all three (all are TODO or DONE)
(should (= (length after-whitelist) 3))
(should (member marker1 after-whitelist))
@@ -105,10 +97,10 @@ Current behavior: blacklist wins, all items filtered out."
(let ((marker1 (point-marker)))
(forward-line 1)
(let ((marker2 (point-marker))
- (chime-keyword-whitelist '("TODO" "DONE"))
- (chime-keyword-blacklist '("TODO" "DONE")))
- (let* ((after-whitelist (chime--apply-whitelist (list marker1 marker2)))
- (after-blacklist (chime--apply-blacklist after-whitelist)))
+ (chime-include-filters `((keywords . ,'("TODO" "DONE"))))
+ (chime-exclude-filters `((keywords . ,'("TODO" "DONE")))))
+ (let* ((after-whitelist (chime--apply-include-filters (list marker1 marker2)))
+ (after-blacklist (chime--apply-exclude-filters after-whitelist)))
;; Whitelist should keep both
(should (= (length after-whitelist) 2))
;; Blacklist should remove both
@@ -133,10 +125,10 @@ Current behavior: blacklist wins (item is filtered out)."
(let ((marker2 (point-marker)))
(forward-line 1)
(let ((marker3 (point-marker))
- (chime-tags-whitelist '("urgent" "important"))
- (chime-tags-blacklist '("urgent"))) ; urgent in both lists
- (let* ((after-whitelist (chime--apply-whitelist (list marker1 marker2 marker3)))
- (after-blacklist (chime--apply-blacklist after-whitelist)))
+ (chime-include-filters `((tags . ,'("urgent" "important"))))
+ (chime-exclude-filters `((tags . ,'("urgent"))))) ; urgent in both lists
+ (let* ((after-whitelist (chime--apply-include-filters (list marker1 marker2 marker3)))
+ (after-blacklist (chime--apply-exclude-filters after-whitelist)))
;; Whitelist should keep urgent and important (markers 1 and 3)
(should (= (length after-whitelist) 2))
(should (member marker1 after-whitelist))
@@ -163,10 +155,10 @@ Current behavior: blacklist wins (OR logic means tag match filters it out)."
(let ((marker1 (point-marker)))
(forward-line 1)
(let ((marker2 (point-marker))
- (chime-keyword-whitelist '("TODO"))
- (chime-tags-blacklist '("urgent")))
- (let* ((after-whitelist (chime--apply-whitelist (list marker1 marker2)))
- (after-blacklist (chime--apply-blacklist after-whitelist)))
+ (chime-include-filters `((keywords . ,'("TODO"))))
+ (chime-exclude-filters `((tags . ,'("urgent")))))
+ (let* ((after-whitelist (chime--apply-include-filters (list marker1 marker2)))
+ (after-blacklist (chime--apply-exclude-filters after-whitelist)))
;; Whitelist should keep TODO (marker1)
(should (= (length after-whitelist) 1))
(should (member marker1 after-whitelist))
@@ -187,10 +179,10 @@ Current behavior: blacklist wins (OR logic means keyword match filters it out)."
(let ((marker1 (point-marker)))
(forward-line 1)
(let ((marker2 (point-marker))
- (chime-tags-whitelist '("urgent"))
- (chime-keyword-blacklist '("TODO")))
- (let* ((after-whitelist (chime--apply-whitelist (list marker1 marker2)))
- (after-blacklist (chime--apply-blacklist after-whitelist)))
+ (chime-include-filters `((tags . ,'("urgent"))))
+ (chime-exclude-filters `((keywords . ,'("TODO")))))
+ (let* ((after-whitelist (chime--apply-include-filters (list marker1 marker2)))
+ (after-blacklist (chime--apply-exclude-filters after-whitelist)))
;; Whitelist should keep urgent tag (marker1)
(should (= (length after-whitelist) 1))
(should (member marker1 after-whitelist))
@@ -219,10 +211,10 @@ Current behavior: only items with conflicts are filtered out."
(let ((marker3 (point-marker)))
(forward-line 1)
(let ((marker4 (point-marker))
- (chime-keyword-whitelist '("TODO"))
- (chime-tags-blacklist '("urgent")))
- (let* ((after-whitelist (chime--apply-whitelist (list marker1 marker2 marker3 marker4)))
- (after-blacklist (chime--apply-blacklist after-whitelist)))
+ (chime-include-filters `((keywords . ,'("TODO"))))
+ (chime-exclude-filters `((tags . ,'("urgent")))))
+ (let* ((after-whitelist (chime--apply-include-filters (list marker1 marker2 marker3 marker4)))
+ (after-blacklist (chime--apply-exclude-filters after-whitelist)))
;; Whitelist should keep TODO (markers 1, 3, 4)
(should (= (length after-whitelist) 3))
(should (member marker1 after-whitelist))