emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Jude DaShiell <jdashiel@shellworld.net>
To: emacs-orgmode@gnu.org
Subject: Re: org-drill and emacspeak (fwd)
Date: Tue, 23 Jul 2013 02:24:59 -0400 (EDT)	[thread overview]
Message-ID: <alpine.BSF.2.01.1307230224400.38320@freire1.furyyjbeyq.arg> (raw)



---------------------------------------------------------------------------
jude <jdashiel@shellworld.net>
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 <bart@ursys.com.au>
To: T. V. Raman <tv.raman.tv@gmail.com>
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".

                 reply	other threads:[~2013-07-23  6:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.BSF.2.01.1307230224400.38320@freire1.furyyjbeyq.arg \
    --to=jdashiel@shellworld.net \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).