Subject: Re: bug#13999: 24.3.50; rng-validate-while-idle -> (error "Selecting deleted buffer")

From: Leo Liu <[email-masked]>
Date: Fri, 22 Mar 2013 22:39:29 +0800

On 2013-03-22 21:36 +0800, Stefan Monnier wrote:
>> The code in rng-valid.el uses the following idiom to redisplay without
>> triggering idle timers.
>
> Why does it need to do that?
>
>
>         Stefan

Does the following make any sense?

(defun rng-validate-while-idle-continue-p ()
  ;; input-pending-p and sit-for run timers that are
  ;; ripe.  Binding timer-idle-list to nil prevents
  ;; this.  If we don't do this, then any ripe timers
  ;; will get run, and we won't get any chance to
  ;; validate until Emacs becomes idle again or until
  ;; the other lower priority timers finish (which
  ;; can take a very long time in the case of
  ;; jit-lock).
  (let ((timer-idle-list nil))
    (and (not (input-pending-p))
	 ;; Fake rng-validate-up-to-date-end so that the mode line
	 ;; shows progress.  Also use this to save point.
	 (let ((rng-validate-up-to-date-end (point)))
	   (goto-char rng-validate-display-point)
	   (when (not rng-validate-display-modified-p)
	     (restore-buffer-modified-p nil))
	   (force-mode-line-update)
	   (let ((continue (sit-for 0)))
	     (goto-char rng-validate-up-to-date-end)
	     continue)))))