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 "firstname.lastname@example.org" with a subject of "unsubscribe" or "help".
If you have questions about this archive or had problems using it, please send mail to:email@example.com No Soliciting!
Emacspeak List Archive | 2010 | 2009 | 2008 | 2007 | 2006 | 2005 | 2004 | 2003 | 2002 | 2001 | 2000 | 1999 | 1998 | Pre 1998
Emacspeak Files | Emacspeak Blog