From ad8c02f37106ba9ffc01ff580e8732614c284262 Mon Sep 17 00:00:00 2001 From: Leon Rische Date: Sun, 7 Mar 2021 15:59:52 +0100 Subject: Move variables / defcustom to org-fc-core --- org-fc-core.el | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++------- org-fc.el | 102 +-------------------------------------------- 2 files changed, 114 insertions(+), 115 deletions(-) diff --git a/org-fc-core.el b/org-fc-core.el index 3fde3f8..47a8b89 100644 --- a/org-fc-core.el +++ b/org-fc-core.el @@ -24,9 +24,111 @@ ;; ;;; Code: +(require 'outline) + (require 'org-indent) (require 'org-element) -(require 'outline) + +;;; Customization + +(defgroup org-fc nil + "Manage and review flashcards with Emacs." + :group 'external + :group 'text) + +(defcustom org-fc-directories '("~/org/") + "Directories to search for flashcards." + :type 'string + :group 'org-fc) + +(defvar org-fc-source-path + (file-name-directory + (file-truename (or load-file-name (buffer-file-name)))) + "Location of the org-fc sources. +Used to generate absolute paths to the awk scripts.") + +(defcustom org-fc-review-history-file (expand-file-name "org-fc-reviews.tsv" user-emacs-directory) + "File to store review results in." + :type 'string + :group 'org-fc) + +(defcustom org-fc-shuffle-positions t + "Shuffle positions before review." + :type 'boolean + :group 'org-fc) + +(defcustom org-fc-append-failed-cards t + "Add failed cards to the end of the review session." + :type 'boolean + :group 'org-fc) + +(defcustom org-fc-index-function #'org-fc-awk-index + "Function used to index cards in a list of paths." + :type 'function + :group 'org-fc) + +;;;; Org Tags / Properties + +(defcustom org-fc-type-property "FC_TYPE" + "Property used to store the cards type." + :type 'string + :group 'org-fc) + +(defcustom org-fc-created-property "FC_CREATED" + "Property used to store the cards creation time." + :type 'string + :group 'org-fc) + +(defcustom org-fc-type-cloze-max-hole-property "FC_CLOZE_MAX" + "Name of the property to use for storing the max hole index." + :type 'string + :group 'org-fc) + +(defcustom org-fc-suspended-tag "suspended" + "Tag for marking suspended cards." + :type 'string + :group 'org-fc) + +(defcustom org-fc-flashcard-tag "fc" + "Tag for marking headlines as flashcards." + :type 'string + :group 'org-fc) + +(defcustom org-fc-demo-tag "fc-demo" + "Tag for marking headlines as demo flashcards. +When demo flashcards are reviewed, their review data is not +updated. This is used for the `org-fc-demo' and for testing card +types." + :type 'string + :group 'org-fc) + +(defcustom org-fc-review-data-drawer "REVIEW_DATA" + "Name of the drawer used to store review data." + :type 'string + :group 'org-fc) + +(defcustom org-fc-drawer-whitelist '() + "Drawers that are not hidden during review." + :type 'list + :group 'org-fc) + +(defcustom org-fc-stats-review-min-box 0 + "Minimum box for reviews to include in the review stats." + :type 'integer + :group 'org-fc) + +;;;; Spacing Parameters + +(defcustom org-fc-algorithm 'sm2-v1 + "Algorithm for spacing reviews of cards." + :type '(choice (const sm2-v1) (const sm2-v2)) + :group 'org-fc) + +(defcustom org-fc-bury-siblings nil + "If non-nil, show at most one position of a card per review. +Does not apply to cloze single and cloze enumeration cards." + :type 'boolean + :group 'org-fc) ;;; Helper Functions @@ -41,9 +143,15 @@ (defun org-fc-noop () "Noop-function.") -(defun org-fc-timestamp-now () - "ISO8601 timestamp of the current time in the UTC timezone." - (format-time-string "%FT%TZ" nil "UTC")) +(defun org-fc-timestamp-in (interval) + "Generate an `org-mode' timestamp INTERVAL days from now." + (let ((seconds (* interval 60 60 24)) + (now (time-to-seconds))) + (format-time-string + org-fc-timestamp-format + "%FT%TZ" + (seconds-to-time (+ now seconds)) + "UTC0"))) (defun org-fc-show-latex () "Show latex fragments of heading at point." @@ -86,15 +194,6 @@ Used to determine if a card uses the compact style." (goto-char (cdr position)) (error "ID %s not found in %s" id file)))) -(defun org-fc-timestamp-in (interval) - "Generate an `org-mode' timestamp INTERVAL days from now." - (let ((seconds (* interval 60 60 24)) - (now (time-to-seconds))) - (format-time-string - org-fc-timestamp-format - (seconds-to-time (+ now seconds)) - "UTC0"))) - (defun org-fc-deemphasize (string) "Remove org emphasis markers from STRING. Returns a pair (marker . body)." @@ -188,7 +287,7 @@ Should only be used by the init functions of card TYPEs." (org-back-to-heading) (org-set-property org-fc-created-property - (org-fc-timestamp-now)) + (org-fc-timestamp-in 0)) (org-set-property org-fc-type-property type) (org-id-get-create) (org-fc--add-tag org-fc-flashcard-tag)) diff --git a/org-fc.el b/org-fc.el index 1a03975..04f6bd4 100644 --- a/org-fc.el +++ b/org-fc.el @@ -31,6 +31,7 @@ (require 'parse-time) (require 'subr-x) +(require 'org-fc-core) (require 'org-fc-compat) (require 'org-fc-awk) @@ -45,107 +46,6 @@ (require 'org-fc-type-text-input) (require 'org-fc-type-cloze) -;;; Customization - -(defgroup org-fc nil - "Manage and review flashcards with Emacs." - :group 'external - :group 'text) - -(defcustom org-fc-directories '("~/org/") - "Directories to search for flashcards." - :type 'string - :group 'org-fc) - -(defvar org-fc-source-path - (file-name-directory - (file-truename (or load-file-name (buffer-file-name)))) - "Location of the org-fc sources. -Used to generate absolute paths to the awk scripts.") - -(defcustom org-fc-review-history-file (expand-file-name "org-fc-reviews.tsv" user-emacs-directory) - "File to store review results in." - :type 'string - :group 'org-fc) - -(defcustom org-fc-shuffle-positions t - "Shuffle positions before review." - :type 'boolean - :group 'org-fc) - -(defcustom org-fc-append-failed-cards t - "Add failed cards to the end of the review session." - :type 'boolean - :group 'org-fc) - -(defcustom org-fc-index-function #'org-fc-awk-index - "Function used to index cards in a list of paths." - :type 'function - :group 'org-fc) - -;;;; Org Tags / Properties - -(defcustom org-fc-type-property "FC_TYPE" - "Property used to store the cards type." - :type 'string - :group 'org-fc) - -(defcustom org-fc-created-property "FC_CREATED" - "Property used to store the cards creation time." - :type 'string - :group 'org-fc) - -(defcustom org-fc-type-cloze-max-hole-property "FC_CLOZE_MAX" - "Name of the property to use for storing the max hole index." - :type 'string - :group 'org-fc) - -(defcustom org-fc-suspended-tag "suspended" - "Tag for marking suspended cards." - :type 'string - :group 'org-fc) - -(defcustom org-fc-flashcard-tag "fc" - "Tag for marking headlines as flashcards." - :type 'string - :group 'org-fc) - -(defcustom org-fc-demo-tag "fc-demo" - "Tag for marking headlines as demo flashcards. -When demo flashcards are reviewed, their review data is not -updated. This is used for the `org-fc-demo' and for testing card -types." - :type 'string - :group 'org-fc) - -(defcustom org-fc-review-data-drawer "REVIEW_DATA" - "Name of the drawer used to store review data." - :type 'string - :group 'org-fc) - -(defcustom org-fc-drawer-whitelist '() - "Drawers that are not hidden during review." - :type 'list - :group 'org-fc) - -(defcustom org-fc-stats-review-min-box 0 - "Minimum box for reviews to include in the review stats." - :type 'integer - :group 'org-fc) - -;;;; Spacing Parameters - -(defcustom org-fc-algorithm 'sm2-v1 - "Algorithm for spacing reviews of cards." - :type '(choice (const sm2-v1) (const sm2-v2)) - :group 'org-fc) - -(defcustom org-fc-bury-siblings nil - "If non-nil, show at most one position of a card per review. -Does not apply to cloze single and cloze enumeration cards." - :type 'boolean - :group 'org-fc) - ;;; Footer (provide 'org-fc) -- cgit v1.2.3