Skip to content

Commit

Permalink
Register algorithms by name
Browse files Browse the repository at this point in the history
  • Loading branch information
l3kn committed Mar 11, 2024
1 parent 5efbaf3 commit fb4dda5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions org-fc-algo-sm2.el
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ Returns nil if there is no history file."
(read output)
(error "Org-fc shell error: %s" output)))))


(org-fc-register-algo 'sm2 org-fc-algo-sm2)

;;; Footer

(provide 'org-fc-algo-sm2)
Expand Down
17 changes: 17 additions & 0 deletions org-fc-core.el
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,23 @@ If point is not inside a flashcard entry, an error is raised."
(org-set-tags
(remove tag (org-get-tags nil 'local))))

;;; Spacing Algorithms

(defvar org-fc-algos '()
"Alist for registering spacing algorithms.
Entries should be lists (name constructor).
Use `org-fc-register-algo' for adding algorithms.")

(defun org-fc-register-algo (name constructor)
"Register a new spacing algorithm NAME using CONSTRUCTOR."
(push (list name constructor) org-fc-algos))

(defun org-fc-algo-constructor (name)
"Get the constructor for spacing algorithm NAME."
(if-let ((entry (alist-get name org-fc-algos nil nil #'string=)))
(cl-first entry)
(error "No such spacing algorithm: %s" name)))

;;; Card Initialization

(defun org-fc--init-card (type)
Expand Down

0 comments on commit fb4dda5

Please sign in to comment.