From f550d134f4a1ad30c425285c4d390f7277cbee32 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sat, 4 Apr 2026 13:32:47 -0500 Subject: Remove dead code and reduce default tooltip lookahead to 1 week Remove chime--agenda-buffer-name (unused variable) and chime--extract-birthday-year (superseded by chime--parse-birthday). Reduce chime-tooltip-lookahead-hours from 8760 (1 year) to 168 (1 week). The 1-year default caused org-agenda-list to scan a 365-day span every check cycle, which is slow for large org collections. The tooltip only shows 5 events, so a week is sufficient for most users. --- chime.el | 13 ++++++------- convert-org-contacts-birthdays.el | 9 --------- tests/test-convert-org-contacts-birthdays.el | 22 ---------------------- 3 files changed, 6 insertions(+), 38 deletions(-) diff --git a/chime.el b/chime.el index 3e0c734..9f3e651 100644 --- a/chime.el +++ b/chime.el @@ -373,16 +373,17 @@ When nil (default), left-click does nothing." :type '(choice (const :tag "No calendar URL" nil) (string :tag "Calendar URL"))) -(defcustom chime-tooltip-lookahead-hours 8760 +(defcustom chime-tooltip-lookahead-hours 168 "Hours ahead to look for events in tooltip. Separate from modeline lookahead window. -Default is 8760 hours (1 year), showing all future events. +Default is 168 hours (1 week). The actual number of events shown is limited by `chime-modeline-tooltip-max-events'. -Set to a smaller value to limit tooltip by time as well as count. -Example: Set to 24 to show only today's and tomorrow's events, -or keep at default to show next N events regardless of distance." +Set to a larger value (e.g., 8760 for 1 year) to see distant events, +or smaller (e.g., 24) for just today and tomorrow. +Note: larger values increase the org-agenda-list span in the async +subprocess, which may slow event checks for large org collections." :package-version '(chime . "0.6.0") :group 'chime :type '(integer :tag "Hours")) @@ -587,8 +588,6 @@ Set to t to enable debug functions: "Count of consecutive async check failures. After `chime-max-consecutive-failures' failures, a warning is displayed.") -(defvar chime--agenda-buffer-name "*chime-agenda*" - "Name for temporary \\='org-agenda\\=' buffer.") (defvar chime--last-check-time (seconds-to-time 0) "Last time checked for events.") diff --git a/convert-org-contacts-birthdays.el b/convert-org-contacts-birthdays.el index eea79a8..373613a 100644 --- a/convert-org-contacts-birthdays.el +++ b/convert-org-contacts-birthdays.el @@ -63,15 +63,6 @@ (require 'org) -(defun chime--extract-birthday-year (birthday-string) - "Extract year from BIRTHDAY-STRING, handling various formats. -Returns nil if no year is present or if year should be ignored. -Handles formats like: - 2000-03-15 - 03-15 - 1985-12-25" - (when (string-match "^\\([0-9]\\{4\\}\\)-[0-9]\\{2\\}-[0-9]\\{2\\}$" birthday-string) - (string-to-number (match-string 1 birthday-string)))) (defun chime--parse-birthday (birthday-string) "Parse BIRTHDAY-STRING into (YEAR MONTH DAY) list. diff --git a/tests/test-convert-org-contacts-birthdays.el b/tests/test-convert-org-contacts-birthdays.el index 3e3c7df..df30870 100644 --- a/tests/test-convert-org-contacts-birthdays.el +++ b/tests/test-convert-org-contacts-birthdays.el @@ -279,28 +279,6 @@ (dolist (file (directory-files (file-name-directory temp-file) t (regexp-quote (file-name-nondirectory backup)))) (delete-file file)))))) -;;; Tests for year extraction - -(ert-deftest test-convert-normal-extract-birthday-year-with-year-returns-year () - "Test extracting year from YYYY-MM-DD returns the year." - (let ((result (chime--extract-birthday-year "2000-03-15"))) - (should (equal result 2000)))) - -(ert-deftest test-convert-normal-extract-birthday-year-without-year-returns-nil () - "Test extracting year from MM-DD returns nil." - (let ((result (chime--extract-birthday-year "03-15"))) - (should (null result)))) - -(ert-deftest test-convert-boundary-extract-birthday-year-very-old-date-returns-year () - "Test extracting year from very old date (1900s) returns the year." - (let ((result (chime--extract-birthday-year "1920-01-01"))) - (should (equal result 1920)))) - -(ert-deftest test-convert-boundary-extract-birthday-year-future-date-returns-year () - "Test extracting year from future date returns the year." - (let ((result (chime--extract-birthday-year "2100-12-31"))) - (should (equal result 2100)))) - ;;; Edge Case Tests (ert-deftest test-convert-edge-duplicate-timestamps-not-added () -- cgit v1.2.3