This repository has been archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathel-secretario-space.el
64 lines (59 loc) · 2.03 KB
/
el-secretario-space.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
;;; el-secretario-space.el --- Spaced repetition module of el-secretario -*- lexical-binding: t; -*-
;;
;; Copyright (C) 2021 Leo
;;
;; Author: Leo <https://github.com/Zetagon>
;; Maintainer: Leo <[email protected]>
;; Created: March 21, 2021
;; Modified: March 21, 2021
;; Version: 0.0.1
;; Keywords:
;; Homepage: https://github.com/Zetagon/el-secretario
;; Package-Requires: ((emacs 26.1) (cl-lib "0.5") (hydra "0.15.0")(org-ql "0.6-pre"))
;;
;; This file is not part of GNU Emacs.
;;
;;; Commentary:
;;
;; Spaced repetition module of el-secretario
;;
;;; Code:
(defun el-secretario-space--increment ()
(let ((cap
(-some-> (org-entry-get (point)
"EL-SECRETARIO-DELTA-CAP")
string-to-number))
(reset-cap
(-some-> (org-entry-get (point)
"EL-SECRETARIO-DELTA-RESET-CAP")
string-to-number)))
(--> (org-entry-get (point)
"EL-SECRETARIO-DELTA")
(or it "0")
(string-to-number it)
(if (and cap (>= it cap))
it
(1+ it))
(if (and reset-cap (>= it reset-cap))
1
it)
(number-to-string it)
(org-set-property "EL-SECRETARIO-DELTA" it))))
(defun el-secretario-space--reset ()
(org-set-property "EL-SECRETARIO-DELTA" "1") )
(defun el-secretario-space-reschedule ()
"Reschedule org entry at point n days into the future.
Where n is incremented by 1 for each time this function is called on that entry"
(let ((delta (org-entry-get (point)
"EL-SECRETARIO-DELTA")))
(org-schedule nil (concat "+" delta "d")))
(el-secretario-space--increment))
(defun el-secretario-space-schedule-and-reset (&optional time)
"Like `org-schedule' but it also resets the delta property.
TIME is passed through to `org-schedule'
Resetting is done with `el-secretario-space-reset'"
(interactive)
(el-secretario-space--reset)
(call-interactively #'org-schedule))
(provide 'el-secretario-space)
;;; el-secretario-space.el ends here