X-Git-Url: https://code.delx.au/gnu-emacs-elpa/blobdiff_plain/ee727e1a7762383634a0548eeb2d4e60bc30c84d..228ec4bb351a9e14e338b9cb09eeb4809957c909:/async-bytecomp.el diff --git a/async-bytecomp.el b/async-bytecomp.el index f1b29a576..2c96da0ad 100644 --- a/async-bytecomp.el +++ b/async-bytecomp.el @@ -1,7 +1,6 @@ -;;; async-bytecomp.el --- Async functions to compile elisp files async +;;; async-bytecomp.el --- Compile elisp files asynchronously -*- lexical-binding: t -*- -;; Copyright (C) 2014 John Wiegley -;; Copyright (C) 2014 Thierry Volpiatto +;; Copyright (C) 2014-2016 Free Software Foundation, Inc. ;; Authors: John Wiegley ;; Thierry Volpiatto @@ -66,27 +65,27 @@ All *.elc files are systematically deleted before proceeding." ;; This happen when recompiling its own directory. (load "async") (let ((call-back - `(lambda (&optional ignore) - (if (file-exists-p async-byte-compile-log-file) - (let ((buf (get-buffer-create byte-compile-log-buffer)) - (n 0)) - (with-current-buffer buf - (goto-char (point-max)) - (let ((inhibit-read-only t)) - (insert-file-contents async-byte-compile-log-file) - (compilation-mode)) - (display-buffer buf) - (delete-file async-byte-compile-log-file) - (unless ,quiet - (save-excursion - (goto-char (point-min)) - (while (re-search-forward "^.*:Error:" nil t) - (cl-incf n))) - (if (> n 0) - (message "Failed to compile %d files in directory `%s'" n ,directory) - (message "Directory `%s' compiled asynchronously with warnings" ,directory))))) - (unless ,quiet - (message "Directory `%s' compiled asynchronously with success" ,directory)))))) + (lambda (&optional _ignore) + (if (file-exists-p async-byte-compile-log-file) + (let ((buf (get-buffer-create byte-compile-log-buffer)) + (n 0)) + (with-current-buffer buf + (goto-char (point-max)) + (let ((inhibit-read-only t)) + (insert-file-contents async-byte-compile-log-file) + (compilation-mode)) + (display-buffer buf) + (delete-file async-byte-compile-log-file) + (unless quiet + (save-excursion + (goto-char (point-min)) + (while (re-search-forward "^.*:Error:" nil t) + (cl-incf n))) + (if (> n 0) + (message "Failed to compile %d files in directory `%s'" n directory) + (message "Directory `%s' compiled asynchronously with warnings" directory))))) + (unless quiet + (message "Directory `%s' compiled asynchronously with success" directory)))))) (async-start `(lambda () (require 'bytecomp) @@ -106,15 +105,21 @@ All *.elc files are systematically deleted before proceeding." (unless quiet (message "Started compiling asynchronously directory %s" directory)))) (defvar package-archive-contents) +(defvar package-alist) (declare-function package-desc-reqs "package.el" (cl-x)) (defun async-bytecomp--get-package-deps (pkg &optional only) ;; Same as `package--get-deps' but parse instead `package-archive-contents' ;; because PKG is not already installed and not present in `package-alist'. - (let* ((pkg-desc (cadr (assq pkg package-archive-contents))) + ;; However fallback to `package-alist' in case PKG no more present + ;; in `package-archive-contents' due to modification to `package-archives'. + ;; See issue #58. + (let* ((pkg-desc (cadr (or (assq pkg package-archive-contents) + (assq pkg package-alist)))) (direct-deps (cl-loop for p in (package-desc-reqs pkg-desc) for name = (car p) - when (assq name package-archive-contents) + when (or (assq name package-archive-contents) + (assq name package-alist)) collect name)) (indirect-deps (unless (eq only 'direct) (delete-dups @@ -146,10 +151,13 @@ All *.elc files are systematically deleted before proceeding." (progn (when (eq cur-package 'async) (fmakunbound 'async-byte-recompile-directory)) - (when (and (string= cur-package "async") - (not (member pkg-dir load-path))) - (push pkg-dir load-path)) - (load "async-bytecomp") + ;; Add to `load-path' the latest version of async and + ;; reload it when reinstalling async. + (when (string= cur-package "async") + (cl-pushnew pkg-dir load-path) + (load "async-bytecomp")) + ;; `async-byte-recompile-directory' will add directory + ;; as needed to `load-path'. (async-byte-recompile-directory (package-desc-dir pkg-desc) t)) ad-do-it)))