From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jude DaShiell Subject: Re: org-drill and emacspeak (fwd) Date: Tue, 23 Jul 2013 02:24:59 -0400 (EDT) Message-ID: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38501) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1W1v-0001X7-Qz for emacs-orgmode@gnu.org; Tue, 23 Jul 2013 02:25:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V1W1t-0006UV-HJ for emacs-orgmode@gnu.org; Tue, 23 Jul 2013 02:25:03 -0400 Received: from shellworld.net ([69.60.117.94]:56417 helo=server1.shellworld.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1W1t-0006RF-7f for emacs-orgmode@gnu.org; Tue, 23 Jul 2013 02:25:01 -0400 Received: from localhost (localhost [127.0.0.1]) by server1.shellworld.net (Postfix) with ESMTP id D0CC122963 for ; Tue, 23 Jul 2013 02:24:59 -0400 (EDT) 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --------------------------------------------------------------------------- jude About to block another web browser version? Ask yourself what Tim Berners-lee would do. ---------- Forwarded message ---------- Date: Mon, 22 Jul 2013 08:11:57 From: Bart Bunting To: T. V. Raman Cc: emacspeak@cs.vassar.edu Subject: Re: org-drill and emacspeak Resent-Date: Mon, 22 Jul 2013 08:12:03 -0400 (EDT) Resent-From: emacspeak@cs.vassar.edu Hi, To revisit a topic that is over a year old. I am once again trying to get org-drill to play nicely with emacspeak. A quick refresher on what it is and where I'm up to: Org drill is like a flash card system for org-mode. Cards are defined and then when org-drill is called the question is shown and then you hit a key to reveal the answer. At that point you are prompted to enter a value of 0 to 5 describing how well you remembered or didn't as the case may be. From that info the item is rescheduled to be drilled again. I have the first bit working for simple cards (there are several types but I'm just working on the most simple case first). So emacspeak reads you the contents of the card. The problem I'm now facing is that the function that is called after the answer is revealed to ask how easily you remembered the card uses a while loop to get input from the user and then calls read-key-sequence to prompt and read the actual key. As well as values 0 to 5 which exit the loop you can use arrow keys to move around the revealed answer. The problem appears to be that anything that emaspeak says as you move lines or for that matter when the answer is revealed is overridden by the prompt asking how well you did. As the prompt is inside the function in a while loop I can't (as far as I can tell) just use emacspeak-speak-messages to nil as in my previous question. Although doing that to read-key-sequence kills the prompt and with the addition of a couple of (emacspeak-speak-line) calls inside the org-drill-reschedule function it half works although you of course lose the prompt altogether and it involves editing the code rather than advising it. I guess that i could some how add the advice to silence read-key-sequence in the start of the around advice to org-drill-reschedule and then remove it at the end of the advice again. Feels hairy and only half achieves what I want. Without adding the emacspeak-speak-line calls inside the org-drill-reschedule function itself nothing is gained at all really. Sorry for the long email hope it made some sort of sense. I've pasted the problematic defun below. Any suggestions on how to tackle this one would be appreciated. Kind regards Bart (defun org-drill-reschedule () "Returns quality rating (0-5), or nil if the user quit." (let ((ch nil) (input nil) (next-review-dates (org-drill-hypothetical-next-review-dates))) (save-excursion (while (not (memq ch '(?q ?e ?0 ?1 ?2 ?3 ?4 ?5))) (setq input (read-key-sequence (if (eq ch ??) (format "0-2 Means you have forgotten the item. 3-5 Means you have remembered the item. 0 - Completely forgot. 1 - Even after seeing the answer, it still took a bit to sink in. 2 - After seeing the answer, you remembered it. 3 - It took you awhile, but you finally remembered. (+%s days) 4 - After a little bit of thought you remembered. (+%s days) 5 - You remembered the item really easily. (+%s days) How well did you do? (0-5, ?=help, e=edit, t=tags, q=quit)" (round (nth 3 next-review-dates)) (round (nth 4 next-review-dates)) (round (nth 5 next-review-dates))) "How well did you do? (0-5, ?=help, e=edit, t=tags, q=quit)"))) (cond ((stringp input) (setq ch (elt input 0))) ((and (vectorp input) (symbolp (elt input 0))) (case (elt input 0) (up (ignore-errors (forward-line -1))) (down (ignore-errors (forward-line 1))) (left (ignore-errors (backward-char))) (right (ignore-errors (forward-char))) (prior (ignore-errors (scroll-down))) ; pgup (next (ignore-errors (scroll-up))))) ; pgdn ((and (vectorp input) (listp (elt input 0)) (eventp (elt input 0))) (case (car (elt input 0)) (wheel-up (ignore-errors (mwheel-scroll (elt input 0)))) (wheel-down (ignore-errors (mwheel-scroll (elt input 0))))))) (if (eql ch ?t) (org-set-tags-command)))) (cond ((and (>= ch ?0) (<= ch ?5)) (let ((quality (- ch ?0)) (failures (org-drill-entry-failure-count))) (unless *org-drill-cram-mode* (save-excursion (org-drill-smart-reschedule quality (nth quality next-review-dates))) (push quality *org-drill-session-qualities*) (cond ((<= quality org-drill-failure-quality) (when org-drill-leech-failure-threshold ;;(setq failures (if failures (string-to-number failures) 0)) ;; (org-set-property "DRILL_FAILURE_COUNT" ;; (format "%d" (1+ failures))) (if (> (1+ failures) org-drill-leech-failure-threshold) (org-toggle-tag "leech" 'on)))) (t (let ((scheduled-time (org-get-scheduled-time (point)))) (when scheduled-time (message "Next review in %d days" (- (time-to-days scheduled-time) (time-to-days (current-time)))) (sit-for 0.5))))) (org-set-property "DRILL_LAST_QUALITY" (format "%d" quality)) (org-set-property "DRILL_LAST_REVIEWED" (time-to-inactive-org-timestamp (current-time)))) quality)) ((= ch ?e) 'edit) (t nil)))) Kind regards Bart ----------------------------------------------------------------------------- To unsubscribe from the emacspeak list or change your address on the emacspeak list send mail to "emacspeak-request@cs.vassar.edu" with a subject of "unsubscribe" or "help".