- ;; Then we go through all the handler and call those that are
- ;; sufficiently ripe.
- (let ((handlers gnus-demon-handler-state)
- handler time idle)
- (while handlers
- (setq handler (pop handlers))
- (cond
- ((numberp (setq time (nth 1 handler)))
- ;; These handlers use a regular timeout mechanism. We decrease
- ;; the timer if it hasn't reached zero yet.
- (unless (zerop time)
- (setcar (nthcdr 1 handler) (decf time)))
- (and (zerop time) ; If the timer now is zero...
- (or (not (setq idle (nth 2 handler))) ; Don't care about idle.
- (and (numberp idle) ; Numerical idle...
- (< idle gnus-demon-idle-time)) ; Idle timed out.
- gnus-demon-is-idle) ; Or just need to be idle.
- ;; So we call the handler.
- (progn
- (funcall (car handler))
- ;; And reset the timer.
- (setcar (nthcdr 1 handler)
- (gnus-demon-time-to-step
- (nth 1 (assq (car handler) gnus-demon-handlers)))))))
- ;; These are only supposed to be called when Emacs is idle.
- ((null (setq idle (nth 2 handler)))
- ;; We do nothing.
- )
- ((not (numberp idle))
- ;; We want to call this handler each and every time that
- ;; Emacs is idle.
- (funcall (car handler)))
- (t
- ;; We want to call this handler only if Emacs has been idle
- ;; for a specified number of timesteps.
- (and (not (memq (car handler) gnus-demon-idle-has-been-called))
- (< idle gnus-demon-idle-time)
- (progn
- (funcall (car handler))
- ;; Make sure the handler won't be called once more in
- ;; this idle-cycle.
- (push (car handler) gnus-demon-idle-has-been-called))))))))
+ ;; Disable all daemonic stuff if we're in the minibuffer
+ (when (and (not (window-minibuffer-p (selected-window)))
+ (not gnus-inhibit-demon))
+ ;; Then we go through all the handler and call those that are
+ ;; sufficiently ripe.
+ (let ((handlers gnus-demon-handler-state)
+ (gnus-inhibit-demon t)
+ ;; Try to avoid dialog boxes, e.g. by Mailcrypt.
+ ;; Unfortunately, Emacs 20's `message-or-box...' doesn't
+ ;; obey `use-dialog-box'.
+ use-dialog-box (last-nonmenu-event 10)
+ handler time idle)
+ (while handlers
+ (setq handler (pop handlers))
+ (cond
+ ((numberp (setq time (nth 1 handler)))
+ ;; These handlers use a regular timeout mechanism. We decrease
+ ;; the timer if it hasn't reached zero yet.
+ (unless (zerop time)
+ (setcar (nthcdr 1 handler) (decf time)))
+ (and (zerop time) ; If the timer now is zero...
+ ;; Test for appropriate idleness
+ (progn
+ (setq idle (nth 2 handler))
+ (cond
+ ((null idle) t) ; Don't care about idle.
+ ((numberp idle) ; Numerical idle...
+ (< idle gnus-demon-idle-time)) ; Idle timed out.
+ (t (< 0 gnus-demon-idle-time)))) ; Or just need to be idle.
+ ;; So we call the handler.
+ (progn
+ (ignore-errors (funcall (car handler)))
+ ;; And reset the timer.
+ (setcar (nthcdr 1 handler)
+ (gnus-demon-time-to-step
+ (nth 1 (assq (car handler) gnus-demon-handlers)))))))
+ ;; These are only supposed to be called when Emacs is idle.
+ ((null (setq idle (nth 2 handler)))
+ ;; We do nothing.
+ )
+ ((and (not (numberp idle))
+ (gnus-demon-is-idle-p))
+ ;; We want to call this handler each and every time that
+ ;; Emacs is idle.
+ (ignore-errors (funcall (car handler))))
+ (t
+ ;; We want to call this handler only if Emacs has been idle
+ ;; for a specified number of timesteps.
+ (and (not (memq (car handler) gnus-demon-idle-has-been-called))
+ (< idle gnus-demon-idle-time)
+ (gnus-demon-is-idle-p)
+ (progn
+ (ignore-errors (funcall (car handler)))
+ ;; Make sure the handler won't be called once more in
+ ;; this idle-cycle.
+ (push (car handler) gnus-demon-idle-has-been-called)))))))))