From 309d651dc90969b71ae24c95a5155a196297133d Mon Sep 17 00:00:00 2001 From: contrapunctus Date: Tue, 17 Nov 2020 08:28:18 +0530 Subject: [PATCH] Fix infinite loop in `chronometrist-report` triggered by non-English locale --- CHANGELOG.md | 1 + elisp/chronometrist-common.el | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f18db9c..fed9e5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Remove quotes from key-value prompt in quit keybindings * Lisp objects being stored as un`read`able strings in `chronometrist-value-history`, resulting in value suggestions not matching user input. * `chronometrist-report` no longer calls `delete-other-windows`; use `chronometrist-report-mode-hook` if it is desired. +* Fixed infinite loop in `chronometrist-report` triggered by non-English locales. ## [0.5.5] - 2020-09-02 ### Added diff --git a/elisp/chronometrist-common.el b/elisp/chronometrist-common.el index c77d8b8..c766a62 100644 --- a/elisp/chronometrist-common.el +++ b/elisp/chronometrist-common.el @@ -144,10 +144,12 @@ If the day of TS is the same as the `chronometrist-report-week-start-day', return TS. TS must be a ts struct (see `ts.el')." - (cl-loop until (equal chronometrist-report-week-start-day - (ts-day-name ts)) - do (ts-decf (ts-day ts)) - finally return ts)) + (cl-loop + with week-start = + (alist-get chronometrist-report-week-start-day chronometrist-report-weekday-number-alist nil nil #'equal) + until (= week-start (ts-dow ts)) + do (ts-decf (ts-day ts)) + finally return ts)) (provide 'chronometrist-common)