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

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

[nongnu] elpa/org-drill 502961433b 196/251: Remove savehist dependency


From: ELPA Syncer
Subject: [nongnu] elpa/org-drill 502961433b 196/251: Remove savehist dependency
Date: Mon, 17 Jan 2022 18:59:17 -0500 (EST)

branch: elpa/org-drill
commit 502961433b28e8146c92ebbaa5a180f7f09e334d
Author: Phillip Lord <phillip.lord@russet.org.uk>
Commit: Phillip Lord <phillip.lord@russet.org.uk>

    Remove savehist dependency
    
    savehist involves switching on a minor mode which does not seem
    optimal.
---
 org-drill.el | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/org-drill.el b/org-drill.el
index 69a8f744e0..5f64d397eb 100644
--- a/org-drill.el
+++ b/org-drill.el
@@ -51,12 +51,11 @@
 
 ;;; Code:
 
-(require 'eieio)
 (require 'cl-lib)
+(require 'eieio)
 (require 'org)
 (require 'org-agenda)
 (require 'org-id)
-(require 'savehist)
 (require 'seq)
 
 (defgroup org-drill nil
@@ -437,16 +436,20 @@ 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.")
 
+(defvar org-drill-persist-location
+  (concat user-emacs-directory "org-drill-sm5-optimal-factor-matrix"))
 
-(add-to-list 'savehist-additional-variables
-             'org-drill-sm5-optimal-factor-matrix)
-
-;; TODO This is used to save -- org-drill-sm5-optimal-factor-matrix
-;; but clearly saves everything else as well. We need a better
-;; solution here.
-(unless savehist-mode
-  (savehist-mode 1))
+(when (file-exists-p org-drill-persist-location)
+  (with-temp-buffer
+    (insert-file-contents org-drill-persist-location)
+    (setq org-drill-sm5-optimal-factor-matrix
+          (read (current-buffer)))))
 
+(defun org-drill-persist ()
+  (with-temp-buffer
+    (print org-drill-sm5-optimal-factor-matrix (current-buffer))
+    (write-region (point-min) (point-max) org-drill-persist-location
+                  nil 'quiet)))
 
 (defun org-drill--transfer-optimal-factor-matrix ()
   (if (and org-drill-optimal-factor-matrix
@@ -3068,10 +3071,8 @@ work correctly with older versions of org mode. Your org 
mode version (%s) appea
       (message nil)
       ))))
 
-
 (defun org-drill-save-optimal-factor-matrix ()
-  (savehist-autosave))
-
+  (org-drill-persist))
 
 (defun org-drill-cram (&optional scope drill-match)
   "Run an interactive drill session in 'cram mode'. In cram mode,



reply via email to

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