From 7f7564612628d31718c2fc1e4471ab7fa29ef3c1 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Tue, 5 May 2026 05:18:59 -0500 Subject: fix: recover from corrupted persist file at package load (upstream #45) Issue #45 (2021): persist-load raised End of file during parsing at persist.el:413 in some configurations, likely from a corrupted persist data file. Pre-fix, this propagated up through the top-level (persist-defvar org-drill-sm5-optimal-factor-matrix ...) form at file-load time and broke the entire package's load. Wrapped the persist-defvar form in condition-case. On failure, the matrix falls back to a fresh nil binding via plain defvar, and a message tells the user what happened. org-drill continues to load normally. --- org-drill.el | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'org-drill.el') diff --git a/org-drill.el b/org-drill.el index 0de606c..489215a 100644 --- a/org-drill.el +++ b/org-drill.el @@ -401,15 +401,26 @@ Available choices are: :group 'org-drill :type '(choice (const sm2) (const sm5) (const simple8))) -(persist-defvar org-drill-sm5-optimal-factor-matrix - nil - "DO NOT CHANGE THE VALUE OF THIS VARIABLE. +;; Wrap `persist-defvar' in `condition-case' so a corrupted persist +;; file (upstream issue #45 — "End of file during parsing" raised from +;; deep inside the persist package) doesn't prevent org-drill from +;; loading. Fall back to a fresh nil matrix when persist-load fails. +(condition-case err + (persist-defvar org-drill-sm5-optimal-factor-matrix + nil + "DO NOT CHANGE THE VALUE OF THIS VARIABLE. Persistent matrix of optimal factors, used by the SuperMemo SM5 algorithm. The matrix is saved at the end of each drill session. Over time, values in the matrix will adapt to the individual user's pace of learning.") + (error + (message + "org-drill: failed to load persisted SM5 matrix (%s); using fresh state" + err) + (defvar org-drill-sm5-optimal-factor-matrix nil + "Persistent matrix of optimal factors (fallback after load failure)."))) (defcustom org-drill-sm5-initial-interval 4.0 -- cgit v1.2.3