For smoother user experience, use run-with-idle-timer for autoload updates.

This commit is contained in:
Dave Abrahams 2011-01-04 12:49:50 -05:00 committed by Dimitri Fontaine
parent 58403c8dc9
commit 309032dcf2

View File

@ -1620,9 +1620,8 @@ This function will run from `post-command-hook', and usually
shouldn't be invoked directly."
(message "el-get: updating outdated autoloads")
(setq el-get-autoload-timer nil) ;; Allow a new update to be primed
;; Don't run again until explicitly added
(remove-hook 'post-command-hook 'el-get-update-autoloads)
(let ((outdated el-get-outdated-autoloads)
;; use dynamic scoping to set up our loaddefs file for
;; update-directory-autoloads
@ -1661,11 +1660,17 @@ with the named PACKAGE"
(autoload-find-destination f))))))
(el-get-save-and-kill el-get-autoload-file))
(defvar el-get-autoload-timer nil
"Where the currently primed autoload timer (if any) is stored")
(defun el-get-invalidate-autoloads ( &optional package )
"Mark the named PACKAGE as needing new autoloads. If PACKAGE
is nil, marks all installed packages as needing new autoloads."
;; If this is the first invalidation, launch the hook
(add-hook 'post-command-hook 'el-get-update-autoloads)
is nil, marks all installed packages as needing new autoloads."
;; Trigger autoload recomputation unless it's already been done
(unless el-get-autoload-timer
(setq el-get-autoload-timer
(run-with-idle-timer 0 nil 'el-get-update-autoloads)))
;; Save the package names for later
(mapc (lambda (p) (add-to-list 'el-get-outdated-autoloads p))