diff options
-rw-r--r-- | org-fc-overlay.el | 15 | ||||
-rw-r--r-- | org-fc-review.el | 28 | ||||
-rw-r--r-- | org-fc-type-cloze.el | 10 | ||||
-rw-r--r-- | org-fc.el | 2 |
4 files changed, 36 insertions, 19 deletions
diff --git a/org-fc-overlay.el b/org-fc-overlay.el index 4fdee9f..ebc6c8e 100644 --- a/org-fc-overlay.el +++ b/org-fc-overlay.el @@ -6,10 +6,10 @@ "Value of point at the end of the previous line. Returns nil if there is no previous line." (save-excursion - (beginning-of-line) - (if (bobp) - nil - (progn (backward-char) + (beginning-of-line) + (if (bobp) + nil + (progn (backward-char) (point))))) (defun org-fc-overlay--point-after-title () @@ -62,6 +62,13 @@ Returns nil if there is no title keyword." (overlay-put o 'invisible t) (overlay-put o 'display "")) +(defun org-fc-show-overlay (o &optional face) + "Show the overlay O using an optional font FACE." + (overlay-put o 'category 'org-fc-hidden) + (overlay-put o 'invisible nil) + (if face + (overlay-put o 'face face))) + ;;;; Hiding Drawers (defun org-fc-hide-drawers () diff --git a/org-fc-review.el b/org-fc-review.el index 64b72d1..a11993a 100644 --- a/org-fc-review.el +++ b/org-fc-review.el @@ -86,18 +86,19 @@ (id (plist-get card :id)) (type (plist-get card :type)) (position (plist-get card :position))) - ;; TODO: org-id-goto already jumps to the file - ;; Check if buffer was already open, - ;; set flag in session (kill buffer?) - (with-current-buffer (find-file path) - (goto-char (point-min)) - (org-fc-id-goto id path) - (org-fc-show-all) - (org-fc-narrow-tree) - (org-fc-hide-drawers) - (org-fc-show-latex) - (outline-hide-subtree) - (funcall (org-fc-type-setup-fn type) position))) + (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 (setq-local org-fc-reviewing-existing-buffer t)) + (goto-char (point-min)) + (org-fc-show-all) + (org-fc-id-goto id path) + ;; Make sure the headline the card is in is expanded + (org-reveal) + (org-fc-narrow-tree) + (org-fc-hide-drawers) + (org-fc-show-latex) + (funcall (org-fc-type-setup-fn type) position)))) (progn (message "Review Done") (setq org-fc-review--current-session nil) @@ -157,7 +158,8 @@ a review session." (org-fc-review-update-data path id position rating) (save-buffer) ;; TODO: Conditional kill - (kill-buffer) + (unless org-fc-reviewing-existing-buffer + (kill-buffer)) (org-fc-review-next-card)))) (defun org-fc-review-update-data (path id position rating) diff --git a/org-fc-type-cloze.el b/org-fc-type-cloze.el index 235c0c7..e483a09 100644 --- a/org-fc-type-cloze.el +++ b/org-fc-type-cloze.el @@ -9,6 +9,11 @@ (defvar org-fc-type-cloze-context 1 "Number of surrounding cards to show for 'context' type cards") +(defface org-fc-type-cloze-hole-face + '((t (:bold t))) + "Face for org-fc cloze card holes." + :group 'org-fc) + (defvar org-fc-type-cloze-hole-re (rx (seq @@ -100,7 +105,10 @@ (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))) + ;; (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) @@ -14,7 +14,7 @@ ;; TODO: a combination of (load-path) and (buffer-file-name) could be ;; used for this -(defcustom org-fc-source-path "~/src/org-flashcards/" +(defcustom org-fc-source-path "~/src/org-fc/" "Location of the org-fc sources, used to generate absolute paths to the awk scripts" :type 'string |