From c13baa10d55ec863d3ceaea48c6b2959ece98198 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sat, 13 Dec 2014 12:25:31 +0000 Subject: [PATCH] emacs-lisp/package.el (package-activate-1): Reload package after upgrade After installing a package, reloads files returned by `package--list-loaded-files'. Fix bug#10125, bug#18443, and bug#18448. --- lisp/ChangeLog | 2 ++ lisp/emacs-lisp/package.el | 20 ++++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index bc34066d001..afe4b355c79 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -3,6 +3,8 @@ * emacs-lisp/package.el (package--list-loaded-files): New function to list files in a given directory which correspond to already loaded files. + (package-activate-1): Reload files given by `package--list-loaded-files'. + Fix bug#10125, bug#18443, and bug#18448. 2014-12-13 Eric S. Raymond diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 654ad3aa3a5..e424e30de1f 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -524,15 +524,27 @@ Return the max version (as a string) if the package is held at a lower version." (error "Internal error: unable to find directory for `%s'" (package-desc-full-name pkg-desc))) ;; Add to load path, add autoloads, and activate the package. - (let ((old-lp load-path)) - (with-demoted-errors - (load (expand-file-name (format "%s-autoloads" name) pkg-dir) nil t)) + (let* ((old-lp load-path) + (autoloads-file (expand-file-name + (format "%s-autoloads" name) pkg-dir)) + (loaded-files-list (package--list-loaded-files pkg-dir))) + (with-demoted-errors (format "Error loading %s: %%s" name) + (load autoloads-file nil t)) (when (and (eq old-lp load-path) (not (or (member pkg-dir load-path) (member pkg-dir-dir load-path)))) ;; Old packages don't add themselves to the `load-path', so we have to ;; do it ourselves. - (push pkg-dir load-path))) + (push pkg-dir load-path)) + ;; Call `load' on all files in `pkg-dir' already present in + ;; `load-history'. This is done so that macros in these files are updated + ;; to their new definitions. If another package is being installed which + ;; depends on this new definition, not doing this update would cause + ;; compilation errors and break the installation. + (with-demoted-errors (format "Error loading %s: %%s" name) + (mapc (lambda (feature) (load feature nil t)) + ;; Skip autoloads file since we already evaluated it above. + (remove (file-truename autoloads-file) loaded-files-list)))) ;; Add info node. (when (file-exists-p (expand-file-name "dir" pkg-dir)) ;; FIXME: not the friendliest, but simple. -- 2.11.4.GIT