summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeon Rische <leon.rische@me.com>2020-01-15 16:30:58 +0100
committerLeon Rische <leon.rische@me.com>2020-01-15 16:30:58 +0100
commit5561ea0ea9b63dc7950ee2fee99c73ec51e42c88 (patch)
tree98b9dcb9966d8382e140743314880f77d6b8f3bd
parent646bdd5adef51b7fe774208486f1c365ba6bb405 (diff)
Remove dash functions / macros
-rw-r--r--org-fc-awk.el8
-rw-r--r--org-fc-dashboard.el1
-rw-r--r--org-fc-review.el11
-rw-r--r--org-fc-type-cloze.el21
-rw-r--r--org-fc.el47
5 files changed, 49 insertions, 39 deletions
diff --git a/org-fc-awk.el b/org-fc-awk.el
index d579fab..d3ca453 100644
--- a/org-fc-awk.el
+++ b/org-fc-awk.el
@@ -91,10 +91,10 @@ parsing each element with its header specification."
(defun org-fc-tsv-parse (headers input)
"Parse a tsv INPUT into a plist, give a list of HEADERS."
- (let* ((lines (split-string input "\n" t)))
- (--map (org-fc-tsv--parse-row
- headers
- (split-string it "\t")) lines)))
+ (mapcar
+ (lambda (row) (org-fc-tsv--parse-row headers (split-string row "\t")))
+ (split-string input "\n" t)))
+
;;;; TSV Headers
(defvar org-fc-awk-card-headers
diff --git a/org-fc-dashboard.el b/org-fc-dashboard.el
index 05a0bdc..62881c7 100644
--- a/org-fc-dashboard.el
+++ b/org-fc-dashboard.el
@@ -126,6 +126,7 @@
(set (make-local-variable 'revert-buffer-function) #'org-fc-dashboard-view)
(setq-local cursor-type nil))
+;;;###autoload
(defun org-fc-dashboard ()
(interactive)
(org-fc-dashboard-view nil nil)
diff --git a/org-fc-review.el b/org-fc-review.el
index 3831d37..4832f72 100644
--- a/org-fc-review.el
+++ b/org-fc-review.el
@@ -71,10 +71,12 @@
(setf (oref session cards) cards)
(org-fc-review-next-card))))))
+;;;###autoload
(defun org-fc-review-buffer ()
(interactive)
(org-fc-review--context 'buffer))
+;;;###autoload
(defun org-fc-review-all ()
(interactive)
(org-fc-review--context 'all))
@@ -90,7 +92,7 @@
(let ((buffer (find-buffer-visiting path)))
(with-current-buffer (find-file path)
;; If buffer was already open, don't kill it after rating the card
- (if buffer
+ (if buffer
(setq-local org-fc-reviewing-existing-buffer t)
(setq-local org-fc-reviewing-existing-buffer nil))
(goto-char (point-min))
@@ -107,7 +109,7 @@
(setq org-fc-review--current-session nil)
(org-fc-show-all))))
-(defhydra org-fc-review-rate-hydra ()
+(defhydra org-fc-review-rate-hydra (:foreign-keys run)
"
%(length (oref org-fc-review--current-session cards)) cards remaining
%s(org-fc-session-stats-string org-fc-review--current-session)
@@ -119,7 +121,7 @@
("e" (org-fc-review-rate-card 'easy) "Rate as easy" :exit t)
("q" org-fc-review-quit "Quit" :exit t))
-(defhydra org-fc-review-flip-hydra ()
+(defhydra org-fc-review-flip-hydra (:foreign-keys run)
"
%(length (oref org-fc-review--current-session cards)) cards remaining
%s(org-fc-session-stats-string org-fc-review--current-session)
@@ -135,7 +137,7 @@
a review session."
(declare (indent defun))
`(if org-fc-review--current-session
- (-if-let (,var (oref org-fc-review--current-session current-item))
+ (if-let ((,var (oref org-fc-review--current-session current-item)))
(if (string= (plist-get ,var :id) (org-id-get))
(progn ,@body)
(message "Flashcard ID mismatch"))
@@ -195,6 +197,7 @@ a review session."
(org-fc-review-next-time next-interval)))
(org-fc-set-review-data data))))))
+;;;###autoload
(defun org-fc-review-quit ()
"Quit the review, remove all overlays from the buffer."
(interactive)
diff --git a/org-fc-type-cloze.el b/org-fc-type-cloze.el
index e483a09..6889b32 100644
--- a/org-fc-type-cloze.el
+++ b/org-fc-type-cloze.el
@@ -99,16 +99,17 @@
overlays)))
(defun org-fc-type-cloze-flip ()
- (-when-let (overlays org-fc-type-cloze--overlays)
- (if (plist-member overlays :separator)
- (org-fc-hide-overlay (plist-get overlays :separator)))
- (if (plist-member overlays :after-hint)
- (org-fc-hide-overlay (plist-get overlays :after-hint)))
- (org-fc-hide-overlay (plist-get overlays :hint))
- ;; (delete-overlay (plist-get overlays :text))
- (org-fc-show-overlay
- (plist-get overlays :text)
- 'org-fc-type-cloze-hole-face))
+ (if-let ((overlays org-fc-type-cloze--overlays))
+ (progn
+ (if (plist-member overlays :separator)
+ (org-fc-hide-overlay (plist-get overlays :separator)))
+ (if (plist-member overlays :after-hint)
+ (org-fc-hide-overlay (plist-get overlays :after-hint)))
+ (org-fc-hide-overlay (plist-get overlays :hint))
+ ;; (delete-overlay (plist-get overlays :text))
+ (org-fc-show-overlay
+ (plist-get overlays :text)
+ 'org-fc-type-cloze-hole-face)))
(org-fc-review-rate-hydra/body))
(defun org-fc-type-cloze-setup (position)
diff --git a/org-fc.el b/org-fc.el
index 0d4dd01..bbef555 100644
--- a/org-fc.el
+++ b/org-fc.el
@@ -1,5 +1,8 @@
(require 'hydra)
+(require 'cl)
+(require 'eieio)
+
(require 'org-fc-overlay)
(require 'org-fc-review)
(require 'org-fc-awk)
@@ -14,13 +17,13 @@
;; TODO: a combination of (load-path) and (buffer-file-name) could be
;; used for this
-(defcustom org-fc-source-path "~/src/org-fc/"
+(defcustom org-fc-source-path nil
"Location of the org-fc sources, used to generate absolute
paths to the awk scripts"
:type 'string
:group 'org-fc)
-(defcustom org-fc-review-history-file "~/org/fc_reviews.tsv"
+(defcustom org-fc-review-history-file nil
"File to store review results in."
:type 'string
:group 'org-fc)
@@ -45,11 +48,6 @@
:type 'string
:group 'org-fc)
-(defcustom org-fc-prefix-key (kbd "C-f")
- "Prefix key for all flashcard key bindings"
- :type 'key-sequence
- :group 'org-fc)
-
(defcustom org-fc-directories '("~/org")
"Directories to search for flashcards"
:type 'string
@@ -211,6 +209,7 @@ FN is called with point at the headline and no arguments."
(org-map-entries
(lambda () (if (org-fc-entry-p) (funcall fn)))))
+;;;###autoload
(defun org-fc-update ()
"Re-process the current flashcard"
(interactive)
@@ -221,6 +220,7 @@ FN is called with point at the headline and no arguments."
(let ((type (org-entry-get (point) "FC_TYPE")))
(funcall (org-fc-type-update-fn type)))))
+;;;###autoload
(defun org-fc-update-all ()
"Re-process all flashcards in the current buffer"
(interactive)
@@ -228,6 +228,7 @@ FN is called with point at the headline and no arguments."
;;; Suspending / Unsuspending Cards
+;;;###autoload
(defun org-fc-suspend-card ()
"Suspend the headline at point if it is a flashcard."
(interactive)
@@ -237,6 +238,7 @@ FN is called with point at the headline and no arguments."
(org-fc-add-tag org-fc-suspended-tag))
(message "Entry at point is not a flashcard")))
+;;;###autoload
(defun org-fc-suspend-buffer ()
"Suspend all cards in the current buffer"
(interactive)
@@ -248,19 +250,20 @@ FN is called with point at the headline and no arguments."
if not, keep the current parameters."
(when (org-fc-suspended-entry-p)
(org-fc-remove-tag org-fc-suspended-tag)
- (-as-> (org-fc-get-review-data) data
- (--map
- (let* ((pos (first it))
- (interval (string-to-number (fourth it)))
- (due (fifth it))
- (days-overdue (org-fc-days-overdue due)))
- (print days-overdue)
- (if (< days-overdue (* org-fc-unsuspend-overdue-percentage interval))
- it
- (org-fc-review-data-default pos)))
- data)
- (org-fc-set-review-data data))))
-
+ ;; Reset all positions overdue more than `org-fc-unsuspend-overdue-percentage'.
+ (org-fc-set-review-data
+ (mapcar
+ (lambda (row)
+ (let* ((pos (first row))
+ (interval (string-to-number (fourth row)))
+ (due (fifth row))
+ (days-overdue (org-fc-days-overdue due)))
+ (if (< days-overdue (* org-fc-unsuspend-overdue-percentage interval))
+ row
+ (org-fc-review-data-default pos))))
+ (org-fc-get-review-data)))))
+
+;;;###autoload
(defun org-fc-unsuspend-card ()
"Un-suspend the headline at point if it is a suspended
flashcard."
@@ -270,10 +273,11 @@ flashcard."
(org-fc--unsuspend-card))
(message "Entry at point is not a suspended flashcard")))
+;;;###autoload
(defun org-fc-unsuspend-buffer ()
"Un-suspend all cards in the current buffer"
(interactive)
- (org-fc-map-cards 'org-fc-unsuspend-card))
+ (org-fc-map-cards 'org-fc--unsuspend-card))
;;; Indexing Cards
@@ -293,6 +297,7 @@ flashcard."
;;; Demo Mode
+;;;###autoload
(defun org-fc-demo ()
"Start a review of the demo file."
(interactive)