From bfcba578aefe0b7d6bad3656462d2b6a538be6d8 Mon Sep 17 00:00:00 2001 From: Leon Rische Date: Sun, 7 Mar 2021 13:09:07 +0100 Subject: Add "after-flip" hook and audio functions --- org-fc-audio.el | 31 +++++++++++++++++++++++-------- org-fc-compat.el | 16 ++++++++++++++++ org-fc.el | 6 ++++++ 3 files changed, 45 insertions(+), 8 deletions(-) diff --git a/org-fc-audio.el b/org-fc-audio.el index ed3d6fe..6be0c73 100644 --- a/org-fc-audio.el +++ b/org-fc-audio.el @@ -37,27 +37,38 @@ (require 'org-fc) -(defcustom org-fc-audio-property-before "FC_AUDIO_BEFORE_SETUP" +(defcustom org-fc-audio-before-setup-property "FC_AUDIO_BEFORE_SETUP" "Name of the property to use for storing before-setup audio files." :type 'string :group 'org-fc) -(defcustom org-fc-audio-property-after "FC_AUDIO_AFTER_SETUP" +(defcustom org-fc-audio-after-setup-property "FC_AUDIO_AFTER_SETUP" "Name of the property to use for storing after-setup audio files." :type 'string :group 'org-fc) -(defun org-fc-audio-set-before (file) +(defcustom org-fc-audio-after-flip-property "FC_AUDIO_AFTER_FLIP" + "Name of the property to use for storing after-flip audio files." + :type 'string + :group 'org-fc) + +(defun org-fc-audio-set-before-setup (file) "Set the befor-setup audio property of the current card to FILE." (interactive "f") (if (org-fc-entry-p) - (org-set-property org-fc-audio-property-before file))) + (org-set-property org-fc-audio-before-setup-property file))) -(defun org-fc-audio-set-after (file) +(defun org-fc-audio-set-after-setup (file) "Set the after-setup audio of the current card to FILE." (interactive "f") (if (org-fc-entry-p) - (org-set-property org-fc-audio-property-after file))) + (org-set-property org-fc-audio-after-setup-property file))) + +(defun org-fc-audio-set-after-flip (file) + "Set the after-setup audio of the current card to FILE." + (interactive "f") + (if (org-fc-entry-p) + (org-set-property org-fc-audio-after-flip-property file))) (defun org-fc-audio-play (property &optional speed) "Play the audio of the current card. @@ -75,11 +86,15 @@ the file at the given speed." (add-hook 'org-fc-before-setup-hook - (lambda () (org-fc-audio-play org-fc-audio-property-before))) + (lambda () (org-fc-audio-play org-fc-audio-before-setup-property))) (add-hook 'org-fc-after-setup-hook - (lambda () (org-fc-audio-play org-fc-audio-property-after))) + (lambda () (org-fc-audio-play org-fc-audio-after-setup-property))) + +(add-hook + 'org-fc-after-flip-hook + (lambda () (org-fc-audio-play org-fc-audio-after-flip-property))) ;;; Footer diff --git a/org-fc-compat.el b/org-fc-compat.el index 78bec4b..dd90894 100644 --- a/org-fc-compat.el +++ b/org-fc-compat.el @@ -79,6 +79,22 @@ 'org-fc-sm2-fuzz-max 'org-fc-algo-sm2-fuzz-max "0.0.1") +(define-obsolete-variable-alias + 'org-fc-audio-property-after + 'org-fc-audio-after-setup-property "0.1.0") + +(define-obsolete-variable-alias + 'org-fc-audio-property-before + 'org-fc-audio-before-setup-property "0.1.0") + +(define-obsolete-function-alias + 'org-fc-audio-set-before + 'org-fc-audio-set-before-setup "0.1.0") + +(define-obsolete-function-alias + 'org-fc-audio-set-after + 'org-fc-audio-set-after-setup "0.1.0") + ;;; Footer (provide 'org-fc-compat) diff --git a/org-fc.el b/org-fc.el index 2c55798..3438a6b 100644 --- a/org-fc.el +++ b/org-fc.el @@ -151,6 +151,11 @@ Does not apply to cloze single and cloze enumeration cards." :type 'hook :group 'org-fc) +(defcustom org-fc-after-flip-hook '() + "Functions run after a card is flipped during review." + :type 'hook + :group 'org-fc) + (defcustom org-fc-before-review-hook '() "Functions run when a review session is started." :type 'hook @@ -1282,6 +1287,7 @@ same ID as the current card in the session." (org-fc-review-with-current-item card (let ((type (plist-get card :type))) (funcall (org-fc-type-flip-fn type)) + (run-hooks 'org-fc-after-flip-hook) (org-fc-review-rate-mode))) (error (org-fc-review-quit) -- cgit v1.2.3