diff options
author | Thanos Apollo <[email protected]> | 2024-11-17 21:37:23 +0200 |
---|---|---|
committer | Thanos Apollo <[email protected]> | 2024-11-17 21:37:23 +0200 |
commit | 3fdcb65b0f73b1e2b88f9e0494ac856192fab56d (patch) | |
tree | 8843eeb37aada4a7ea6b5684a99a13ef8203448b | |
parent | 01c37bdbc739cf9199735a078ca15ec56e4f0959 (diff) |
dashboard-streak: Limit to 666 days
* Limit possible streak value to 666 days, avoiding max-lisp-eval-depth.
-rw-r--r-- | gnosis.el | 17 |
1 files changed, 9 insertions, 8 deletions
@@ -2648,16 +2648,18 @@ If STRING-SECTION is nil, apply FACE to the entire STRING." (gnosis-dashboard-output-tags))))) (defun gnosis-dashboard--streak (dates &optional num date) - "Return current review streak. + "Return current review streak number as a string. -DATES: Dates in the activity log. +DATES: Dates in the activity log, a list of dates in (YYYY MM DD). NUM: Streak number. DATE: Integer, used with `gnosis-algorithm-date' to get previous dates." (let ((num (or num 0)) (date (or date 0))) - (if (member (gnosis-algorithm-date date) dates) - (gnosis-dashboard--streak dates (cl-incf num) (- date 1)) - num))) + (cond ((> num 666) + "+666") ;; do not go over 666, avoiding `max-lisp-eval-depth' + ((member (gnosis-algorithm-date date) dates) + (gnosis-dashboard--streak dates (cl-incf num) (- date 1))) + (t (number-to-string num))))) (defun gnosis-dashboard-output-average-rev () "Output the average daily notes reviewed for current year. @@ -3060,9 +3062,8 @@ DASHBOARD-TYPE: either Notes or Decks to display the respective dashboard." (insert (gnosis-center-string (format "Current streak: %s days" (propertize - (number-to-string - (gnosis-dashboard--streak - (gnosis-select 'date 'activity-log '1=1 t))) + (gnosis-dashboard--streak + (gnosis-select 'date 'activity-log '1=1 t)) 'face 'success)))) (insert "\n\n")) (pop-to-buffer-same-window buffer) |