emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/gnosis 3fdcb65b0f 2/7: dashboard-streak: Limit to 666 days


From: ELPA Syncer
Subject: [nongnu] elpa/gnosis 3fdcb65b0f 2/7: dashboard-streak: Limit to 666 days
Date: Tue, 10 Dec 2024 13:00:30 -0500 (EST)

branch: elpa/gnosis
commit 3fdcb65b0f73b1e2b88f9e0494ac856192fab56d
Author: Thanos Apollo <public@thanosapollo.org>
Commit: Thanos Apollo <public@thanosapollo.org>

    dashboard-streak: Limit to 666 days
    
    * Limit possible streak value to 666 days, avoiding max-lisp-eval-depth.
---
 gnosis.el | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/gnosis.el b/gnosis.el
index 28efbf9662..16625a7533 100644
--- a/gnosis.el
+++ b/gnosis.el
@@ -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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]