org-drill: prevent fontifcation functions from being called when saving outline

visibility info during drill sessions. This should fix slow transitions between drill
items for some people.
This commit is contained in:
Paul Sexton 2012-05-06 10:45:39 +12:00
parent b3224994bf
commit eb48e426d5
1 changed files with 34 additions and 49 deletions

View File

@ -1976,23 +1976,6 @@ visible content of the card."
(org-drill-hide-subheadings-if 'org-drill-entry-p))))) (org-drill-hide-subheadings-if 'org-drill-entry-p)))))
;;; The following macro is necessary because `org-save-outline-visibility'
;;; currently discards the value returned by its body and returns a garbage
;;; value instead. (as at org mode v 7.5)
(defmacro org-drill-save-visibility (&rest body)
"Store the current visibility state of the org buffer, and restore it
after executing BODY. Return the value of the last expression
in BODY."
(let ((retval (gensym)))
`(let ((,retval nil))
(org-save-outline-visibility t
(setq ,retval
(progn
,@body)))
,retval)))
(defun org-drill-entry () (defun org-drill-entry ()
"Present the current topic for interactive review, as in `org-drill'. "Present the current topic for interactive review, as in `org-drill'.
Review will occur regardless of whether the topic is due for review or whether Review will occur regardless of whether the topic is due for review or whether
@ -2012,38 +1995,41 @@ See `org-drill' for more details."
;; (org-back-to-heading)) ;; (org-back-to-heading))
(let ((card-type (org-entry-get (point) "DRILL_CARD_TYPE")) (let ((card-type (org-entry-get (point) "DRILL_CARD_TYPE"))
(answer-fn 'org-drill-present-default-answer) (answer-fn 'org-drill-present-default-answer)
(cont nil)) (cont nil)
(org-drill-save-visibility ;; fontification functions in `outline-view-change-hook' can cause big
(save-restriction ;; slowdowns, so we temporarily bind this variable to nil here.
(org-narrow-to-subtree) (outline-view-change-hook nil))
(org-show-subtree) (org-save-outline-visibility t
(org-cycle-hide-drawers 'all) (save-restriction
(org-narrow-to-subtree)
(org-show-subtree)
(org-cycle-hide-drawers 'all)
(let ((presentation-fn (cdr (assoc card-type org-drill-card-type-alist)))) (let ((presentation-fn (cdr (assoc card-type org-drill-card-type-alist))))
(if (listp presentation-fn) (if (listp presentation-fn)
(psetq answer-fn (or (second presentation-fn) (psetq answer-fn (or (second presentation-fn)
'org-drill-present-default-answer) 'org-drill-present-default-answer)
presentation-fn (first presentation-fn))) presentation-fn (first presentation-fn)))
(cond (cond
((null presentation-fn) ((null presentation-fn)
(message "%s:%d: Unrecognised card type '%s', skipping..." (message "%s:%d: Unrecognised card type '%s', skipping..."
(buffer-name) (point) card-type) (buffer-name) (point) card-type)
(sit-for 0.5) (sit-for 0.5)
'skip) 'skip)
(t (t
(setq cont (funcall presentation-fn)) (setq cont (funcall presentation-fn))
(cond (cond
((not cont) ((not cont)
(message "Quit") (message "Quit")
nil) nil)
((eql cont 'edit) ((eql cont 'edit)
'edit) 'edit)
((eql cont 'skip) ((eql cont 'skip)
'skip) 'skip)
(t (t
(save-excursion (save-excursion
(funcall answer-fn (funcall answer-fn
(lambda () (org-drill-reschedule))))))))))))) (lambda () (org-drill-reschedule)))))))))))))
(defun org-drill-entries-pending-p () (defun org-drill-entries-pending-p ()
@ -3013,4 +2999,3 @@ returns its return value."
(provide 'org-drill) (provide 'org-drill)