aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-05 05:15:59 -0500
committerCraig Jennings <c@cjennings.net>2026-05-05 05:15:59 -0500
commite4a254453dedacafcca883a3b20302762c872280 (patch)
tree03c4bfdd3384ab0dba34017e9b7b7dffe12aad41
parentfda1e989e0c22433b0214ab537a61852d906fd4b (diff)
downloadchime-e4a254453dedacafcca883a3b20302762c872280.tar.gz
chime-e4a254453dedacafcca883a3b20302762c872280.zip
fix: skip declined events in tooltip, modeline, and notifications
org-gcal writes `:STATUS: declined' on calendar entries the user has declined, and chime was happily showing them in the tooltip, modeline, and notification stream — which defeats the whole point of declining a meeting. I added `chime-declined-events-predicate', mirroring the shape of `chime-done-keywords-predicate', and put it on the default `chime-predicate-blacklist'. The match is on the literal lowercase value because that's what real org-gcal exports use; uppercase or other values pass through. Users who want declined events back can pop the predicate off the blacklist. Tests cover all four STATUS values seen in real org-gcal data (accepted, declined, needs-action, tentative), plus the no-property, empty-property, todo-keyword-still-attached, gibberish-value, case-sensitivity, and default-blacklist-membership cases.
-rw-r--r--chime.el11
-rw-r--r--tests/test-chime-declined-events-predicate.el156
2 files changed, 166 insertions, 1 deletions
diff --git a/chime.el b/chime.el
index f33a7c1..cd47d19 100644
--- a/chime.el
+++ b/chime.el
@@ -262,7 +262,8 @@ running the async command to check notifications."
:type '(repeat string))
(defcustom chime-predicate-blacklist
- '(chime-done-keywords-predicate)
+ '(chime-done-keywords-predicate
+ chime-declined-events-predicate)
"Never receive notifications for events matching these predicates.
Each function should take an event POM and return non-nil iff that event should
not trigger a notification."
@@ -1280,6 +1281,14 @@ Combines keyword, tag, and custom predicate blacklists."
(goto-char (marker-position marker))
(member (nth 2 (org-heading-components)) org-done-keywords))))
+(defun chime-declined-events-predicate (marker)
+ "Return non-nil when entry at MARKER carries `:STATUS: declined'.
+This is the marker org-gcal writes for events the user has declined in
+their calendar. Only the literal lowercase `declined' value is matched
+because that is what real org-gcal exports use."
+ (let ((status (org-entry-get marker "STATUS")))
+ (and status (string= status "declined"))))
+
(defun chime--apply-whitelist (markers)
"Apply whitelist to MARKERS."
(-if-let (whitelist-predicates (chime--whitelist-predicates))
diff --git a/tests/test-chime-declined-events-predicate.el b/tests/test-chime-declined-events-predicate.el
new file mode 100644
index 0000000..ca25faa
--- /dev/null
+++ b/tests/test-chime-declined-events-predicate.el
@@ -0,0 +1,156 @@
+;;; test-chime-declined-events-predicate.el --- Tests for chime-declined-events-predicate -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2026 Craig Jennings
+
+;; Author: Craig Jennings <c@cjennings.net>
+
+;; This program is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Tests for the predicate that filters out events the user declined in
+;; their calendar. org-gcal stores the attendee response in a `:STATUS:'
+;; property; the values seen in real calendar exports are accepted,
+;; declined, needs-action, and tentative. Only "declined" should match.
+
+;;; Code:
+
+(require 'test-bootstrap (expand-file-name "test-bootstrap.el"))
+
+;;;; Normal Cases
+
+(ert-deftest test-chime-declined-events-predicate-declined-status ()
+ "Normal: an event whose STATUS property is `declined' returns non-nil."
+ (with-temp-buffer
+ (org-mode)
+ (insert "* Meeting\n")
+ (insert ":PROPERTIES:\n")
+ (insert ":STATUS: declined\n")
+ (insert ":END:\n")
+ (insert "<2026-05-06 Wed 10:00>\n")
+ (goto-char (point-min))
+ (let ((marker (point-marker)))
+ (should (chime-declined-events-predicate marker)))))
+
+(ert-deftest test-chime-declined-events-predicate-accepted-status ()
+ "Normal: an event whose STATUS property is `accepted' returns nil."
+ (with-temp-buffer
+ (org-mode)
+ (insert "* Meeting\n")
+ (insert ":PROPERTIES:\n")
+ (insert ":STATUS: accepted\n")
+ (insert ":END:\n")
+ (insert "<2026-05-06 Wed 10:00>\n")
+ (goto-char (point-min))
+ (let ((marker (point-marker)))
+ (should-not (chime-declined-events-predicate marker)))))
+
+(ert-deftest test-chime-declined-events-predicate-tentative-status ()
+ "Normal: tentative events still surface (only declined gets filtered)."
+ (with-temp-buffer
+ (org-mode)
+ (insert "* Meeting\n")
+ (insert ":PROPERTIES:\n")
+ (insert ":STATUS: tentative\n")
+ (insert ":END:\n")
+ (goto-char (point-min))
+ (let ((marker (point-marker)))
+ (should-not (chime-declined-events-predicate marker)))))
+
+(ert-deftest test-chime-declined-events-predicate-needs-action-status ()
+ "Normal: needs-action events still surface so the user can act on them."
+ (with-temp-buffer
+ (org-mode)
+ (insert "* Meeting\n")
+ (insert ":PROPERTIES:\n")
+ (insert ":STATUS: needs-action\n")
+ (insert ":END:\n")
+ (goto-char (point-min))
+ (let ((marker (point-marker)))
+ (should-not (chime-declined-events-predicate marker)))))
+
+;;;; Boundary Cases
+
+(ert-deftest test-chime-declined-events-predicate-no-status-property ()
+ "Boundary: a heading with no STATUS property returns nil."
+ (with-temp-buffer
+ (org-mode)
+ (insert "* Plain heading\n<2026-05-06 Wed 10:00>\n")
+ (goto-char (point-min))
+ (let ((marker (point-marker)))
+ (should-not (chime-declined-events-predicate marker)))))
+
+(ert-deftest test-chime-declined-events-predicate-empty-status-property ()
+ "Boundary: an empty STATUS property returns nil."
+ (with-temp-buffer
+ (org-mode)
+ (insert "* Heading\n")
+ (insert ":PROPERTIES:\n")
+ (insert ":STATUS: \n")
+ (insert ":END:\n")
+ (goto-char (point-min))
+ (let ((marker (point-marker)))
+ (should-not (chime-declined-events-predicate marker)))))
+
+(ert-deftest test-chime-declined-events-predicate-declined-with-todo-keyword ()
+ "Boundary: a declined event with a TODO keyword still matches."
+ (with-temp-buffer
+ (org-mode)
+ (insert "* TODO Meeting\n")
+ (insert ":PROPERTIES:\n")
+ (insert ":STATUS: declined\n")
+ (insert ":END:\n")
+ (goto-char (point-min))
+ (let ((marker (point-marker)))
+ (should (chime-declined-events-predicate marker)))))
+
+(ert-deftest test-chime-declined-events-predicate-case-insensitive ()
+ "Boundary: org-entry-get returns the value as written; uppercase
+DECLINED does not match. This documents the contract — the predicate
+is case-sensitive because real org-gcal data uses lowercase verbatim."
+ (with-temp-buffer
+ (org-mode)
+ (insert "* Meeting\n")
+ (insert ":PROPERTIES:\n")
+ (insert ":STATUS: DECLINED\n")
+ (insert ":END:\n")
+ (goto-char (point-min))
+ (let ((marker (point-marker)))
+ (should-not (chime-declined-events-predicate marker)))))
+
+;;;; Error Cases
+
+(ert-deftest test-chime-declined-events-predicate-unrelated-status-value ()
+ "Error: a STATUS value chime doesn't recognise returns nil rather
+than treating it as declined."
+ (with-temp-buffer
+ (org-mode)
+ (insert "* Meeting\n")
+ (insert ":PROPERTIES:\n")
+ (insert ":STATUS: gibberish\n")
+ (insert ":END:\n")
+ (goto-char (point-min))
+ (let ((marker (point-marker)))
+ (should-not (chime-declined-events-predicate marker)))))
+
+;;;; Integration with the default predicate-blacklist
+
+(ert-deftest test-chime-declined-events-predicate-on-default-blacklist ()
+ "Normal: the predicate ships in the default `chime-predicate-blacklist'
+so out-of-the-box installs hide declined events without extra config."
+ (should (memq 'chime-declined-events-predicate
+ (default-value 'chime-predicate-blacklist))))
+
+(provide 'test-chime-declined-events-predicate)
+;;; test-chime-declined-events-predicate.el ends here