aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2024-04-26 12:21:31 +0300
committerThanos Apollo <[email protected]>2024-04-26 12:21:31 +0300
commit1d5bc2fca56b158726626e3e414f4fcf993fc52a (patch)
treeabb0af6fca3267750732183b48150682e4a3a7a3
parenta2b59188dfcebc7c666f8f75a60035638a65c798 (diff)
[fix] modeline: Improve performance
Calling (length (gnosis-review-get-due-notes)) causes performance issues, especially on old hardware, we store the value on a variable and update it every 5 minutes or when we finish a review session.
-rw-r--r--gnosis.el8
1 files changed, 5 insertions, 3 deletions
diff --git a/gnosis.el b/gnosis.el
index 9cd3d3c..cd02b88 100644
--- a/gnosis.el
+++ b/gnosis.el
@@ -1,4 +1,4 @@
-;;; gnosis.el --- Spaced Repetition System For Note Taking & Self Testing -*- lexical-binding: t; -*-
+;;; gnosis.el --- Spaced Repetition System -*- lexical-binding: t; -*-
;; Copyright (C) 2023 Thanos Apollo
@@ -1298,7 +1298,8 @@ NOTES: List of note ids"
(recursive-edit))
(?q (gnosis-review-commit note-count)
(cl-return))))
- finally (gnosis-review-commit note-count))))))
+ finally (gnosis-review-commit note-count)))
+ (setq gnosis-due-notes (length (gnosis-review-get-due-notes))))))
;; Editing notes
@@ -1871,13 +1872,14 @@ DASHBOARD-TYPE: either 'Notes' or 'Decks' to display the respective dashboard."
(if gnosis-modeline-mode
(progn
(add-to-list 'global-mode-string '(:eval
- (format " G:%d" (length (gnosis-review-get-due-notes)))))
+ (format " G:%d" gnosis-due-notes)))
(force-mode-line-update))
(setq global-mode-string
(seq-remove (lambda (item)
(and (listp item) (eq (car item) :eval)
(string-prefix-p " G:" (format "%s" (eval (cadr item))))))
global-mode-string))
+ (run-at-time "5 min" 300 #'(lambda () (setq gnosis-due-notes (length (gnosis-review-get-due-notes)))))
(force-mode-line-update)))
(define-derived-mode gnosis-mode special-mode "Gnosis"