From mboxrd@z Thu Jan 1 00:00:00 1970 From: stardiviner Subject: Re: [PATCH] Add feature to org-drill to auto pronounce word Date: Tue, 29 Jan 2019 18:40:34 +0800 Message-ID: <87h8drkaql.fsf@gmail.com> References: <87r2dmmd8g.fsf@gmail.com> <87a7jqdtep.fsf@gmail.com> <87k1iry7e6.fsf@nicolasgoaziou.fr> <87womqhl0a.fsf@gmail.com> <87sgxdx0ni.fsf@nicolasgoaziou.fr> Reply-To: numbchild@gmail.com Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([209.51.188.92]:44851) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gocVl-0000bN-TN for emacs-orgmode@gnu.org; Tue, 29 Jan 2019 18:09:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gocVi-0005rQ-OO for emacs-orgmode@gnu.org; Tue, 29 Jan 2019 18:09:45 -0500 Received: from [220.187.130.43] (port=58753 helo=dark.localdomain) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gocVa-0005fm-DM for emacs-orgmode@gnu.org; Tue, 29 Jan 2019 18:09:37 -0500 In-reply-to: <87sgxdx0ni.fsf@nicolasgoaziou.fr> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Nicolas Goaziou Cc: Paul Sexton , org-mode --=-=-= Content-Type: text/plain Nicolas Goaziou writes: > Hello, > > stardiviner writes: > >> Nicolas Goaziou writes: >> >>> Hello, >>> >>> stardiviner writes: >>> >>>> A gentle ping.. >>> >>> I'm not sure "org-drill.el" is still actively maintained. I'm Cc'ing >>> Paul Sexton. In the long run, I think this package could be packaged >>> through ELPA instead. >> >> It is indeed not actively maintained. But still has some user are using >> it. I found some recently used in Org Mode ML mentioned it. >> >> I will ping the author Paul Sexton, I would like to particited in >> maintain it. If he agree to publish it to MELPA, I could help. > > Did you forget to add the new patch? Or is it intentional? > > > Regards, Oh, sorry, seems yes. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-org-drill.el-Add-feature-let-org-drill-auto-pronounc.patch >From b95a90cbecdf4fa2f47079eed08d2395f2700d41 Mon Sep 17 00:00:00 2001 From: stardiviner Date: Sun, 27 Jan 2019 10:43:37 +0800 Subject: [PATCH] org-drill.el: Add feature let org-drill auto pronounce * contrib/lisp/org-drill.el (org-drill-entry, org-drill-entry-before-hook, org-drill-entry-after-hook): Add two hooks around ~org-drill-entry~. (org-drill-auto-pronounce): option to toggle this functionality. (org-drill-pronounce-command,org-drill-pronounce-command-args): option to specify the pronounce command and arguments. (org-drill-pronounce-word): The real function to pronounce word. (org-drill-hide-subheadings-if): fix issue in Org 9.2 version. --- contrib/lisp/org-drill.el | 45 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/contrib/lisp/org-drill.el b/contrib/lisp/org-drill.el index c7f509bff..39785e7e3 100644 --- a/contrib/lisp/org-drill.el +++ b/contrib/lisp/org-drill.el @@ -532,6 +532,35 @@ exponential effect on inter-repetition spacing." :type 'float) +(defcustom org-drill-entry-before-hook nil + "A hook to run functions when every org-drill entry." + :type 'hook + :group 'org-drill) + +(defcustom org-drill-entry-after-hook nil + "A hook to run functions when every org-drill entry." + :type 'hook + :group 'org-drill) + +(defcustom org-drill-auto-pronounce t + "Auto pronounce org-drill word if non-nil." + :type 'boolean + :safe #'booleanp + :group 'org-drill) + +(defcustom org-drill-pronounce-command "" + "Org-drill pronounce command." + :type 'string + :safe #'stringp + :group 'org-drill) + +(defcustom org-drill-pronounce-command-args "" + "Org-drill pronounce command arguments." + :type 'string + :safe #'stringp + :group 'org-drill) + + (defvar drill-answer nil "Global variable that can be bound to a correct answer when an item is being presented. If this variable is non-nil, the default @@ -1486,7 +1515,7 @@ the current topic." (funcall test)) (hide-subtree)) (push (point) drill-sections))) - "" 'tree)) + nil 'tree)) (reverse drill-sections))) @@ -2163,6 +2192,15 @@ If ANSWER is supplied, set the global variable `drill-answer' to its value." (prog1 (org-drill-presentation-prompt) (org-drill-hide-subheadings-if 'org-drill-entry-p))))) +(defun org-drill-pronounce-word () + "Pronounce word after querying." + (when org-drill-auto-pronounce + (shell-command-to-string + (format "%s %s %s &" + org-drill-pronounce-command org-drill-pronounce-command-args + (shell-quote-argument + (substring-no-properties + (org-get-heading 'no-tags 'no-todo 'no-priority 'no-comment))))))) (defun org-drill-entry () "Present the current topic for interactive review, as in `org-drill'. @@ -2202,6 +2240,7 @@ See `org-drill' for more details." 'org-drill-present-default-answer) present-empty-cards (third presentation-fn) presentation-fn (first presentation-fn))) + (run-hook-with-args 'org-drill-entry-before-hook) (prog1 (cond ((null presentation-fn) @@ -2223,7 +2262,9 @@ See `org-drill' for more details." (save-excursion (funcall answer-fn (lambda () (org-drill-reschedule)))))))) - (org-remove-latex-fragment-image-overlays))))))) + (when org-drill-auto-pronounce org-drill-pronounce-word) + (run-hook-with-args 'org-drill-entry-after-hook) + (org-remove-latex-fragment-image-overlays))))))) (defun org-drill-entries-pending-p () -- 2.20.1 --=-=-= Content-Type: text/plain -- [ stardiviner ] I try to make every word tell the meaning what I want to express. Blog: https://stardiviner.github.io/ IRC(freenode): stardiviner, Matrix: stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3 --=-=-=--