Fix problems with autoloads.

Note that the new dependencies code ensures that we have only one package
currently installing at any time, so that we don't need timer and defered
autoloads updating anymore.  That simplifies the code a lot, and I think it
fixes issue #400, will check that next.
This commit is contained in:
Dimitri Fontaine 2011-09-23 11:41:24 +02:00
parent a2202e9212
commit 6b6f06567f
2 changed files with 15 additions and 50 deletions

View File

@ -48,17 +48,12 @@
(el-get-verbose-message "el-get: evaluating autoload file")
(el-get-load-fast el-get-autoload-file)))
(defun el-get-update-autoloads ()
"Regenerate, compile, and load any outdated packages' autoloads.
This function will run from a timer, and usually
shouldn't be invoked directly."
(defun el-get-update-autoloads (package)
"Regenerate, compile, and load any outdated packages' autoloads."
(message "el-get: updating outdated autoloads")
(setq el-get-autoload-timer nil) ;; Allow a new update to be primed
(let ((outdated el-get-outdated-autoloads)
;; Generating autoloads runs theses hooks; disable then
(let (;; Generating autoloads runs theses hooks; disable then
fundamental-mode-hook
prog-mode-hook
emacs-lisp-mode-hook
@ -69,12 +64,8 @@ shouldn't be invoked directly."
;; make sure we can actually byte-compile it
(el-get-ensure-byte-compilable-autoload-file generated-autoload-file)
;; clear the list early in case of errors
(setq el-get-outdated-autoloads nil)
(dolist (p outdated)
(if (string= (el-get-package-status p) "installed")
(apply 'update-directory-autoloads (el-get-load-path p))))
(when (string= (el-get-package-status package) "installed")
(apply 'update-directory-autoloads (el-get-load-path package)))
(el-get-save-and-kill el-get-autoload-file)
@ -91,9 +82,6 @@ shouldn't be invoked directly."
(defun el-get-remove-autoloads (package)
"Remove from `el-get-autoload-file' any autoloads associated
with the named PACKAGE"
;; Remove any compiled loaddefs file and schedule it for recompilation
(el-get-schedule-autoload-update)
(when (file-exists-p el-get-autoload-file)
(with-temp-buffer ;; empty buffer to trick `autoload-find-destination'
(let ((generated-autoload-file el-get-autoload-file)
@ -108,10 +96,7 @@ with the named PACKAGE"
(if (> emacs-major-version 23)
(autoload-find-destination f (autoload-file-load-name f))
(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")
(el-get-update-autoloads package)))
(defun el-get-want-autoloads-p (package)
"Return t iff the given PACKAGE should have its autoloads
@ -120,39 +105,20 @@ automatically generated by el-get"
(or (not (plist-member source :autoloads))
(eq (plist-get source :autoloads) t))))
(defun el-get-schedule-autoload-update ()
"Autoloads need to be updated; delete any (now outdated)
compiled autoloads file and schedule the task to run later."
(let ((elc (concat (file-name-sans-extension el-get-autoload-file) ".elc")))
(when (file-exists-p elc)
(delete-file elc)))
(unless (or el-get-autoload-timer
(not el-get-generate-autoloads))
(setq el-get-autoload-timer
(run-with-idle-timer 0 nil 'el-get-update-autoloads))))
(defun el-get-invalidate-autoloads ( &optional package )
(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."
;; Trigger autoload recomputation unless it's already been done
(unless (or el-get-autoload-timer
(not el-get-generate-autoloads))
(setq el-get-autoload-timer
(run-with-idle-timer 0 nil 'el-get-update-autoloads)))
;; Save the package names for later
(mapc (lambda (p)
(when (el-get-want-autoloads-p p)
(add-to-list 'el-get-outdated-autoloads p)))
(if package (list package)
(el-get-list-package-names-with-status "installed")))
;; If we're invalidating everything, try to start from a clean slate
(unless package
(ignore-errors
(delete-file el-get-autoload-file)
(delete-file
(concat (file-name-sans-extension el-get-autoload-file) ".elc")))))
(concat (file-name-sans-extension el-get-autoload-file) ".elc"))))
(let ((packages
(if package (list package)
(el-get-list-package-names-with-status "installed"))))
(mapc 'el-get-update-autoloads packages)))
(provide 'el-get-autoloads)

View File

@ -181,8 +181,7 @@
(require 'el-get-dependencies) ; topological-sort of package dep graph
(require 'el-get-notify) ; notification support (dbus, growl...)
(require 'el-get-list-packages) ; menu and `el-get-describe' facilities
(require 'el-get-autoloads) ; to be removed^W cleaned up next
(require 'el-get-autoloads) ; manages updating el-get's loaddefs.el
;;
;; And then define some more code-level customs. They stay here so that
@ -664,7 +663,7 @@ already installed packages is considered."
(error "el-get sync parameter should be either nil, sync or wait"))
;; If there's no autoload file, everything needs to be regenerated.
(if (not (file-exists-p el-get-autoload-file)) (el-get-invalidate-autoloads))
(unless (file-exists-p el-get-autoload-file) (el-get-invalidate-autoloads))
;; Autoloads path are relative to el-get-dir, so add it to load-path
(add-to-list 'load-path (file-name-as-directory el-get-dir))