diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a93c9ec..f72c8edd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,8 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how ## 0.7.x (Unreleased) > Released N/A -* Avoid loading package info unless it's needed (#13) +* Avoid loading package info unless it's needed (#13, #14, and #19) +* Read `-pkg.el` file prior to package-file while exists (#21) ## 0.6.17 > Released Mar 5, 2022 diff --git a/lisp/_prepare.el b/lisp/_prepare.el index 831a18f6..bc039fb6 100644 --- a/lisp/_prepare.el +++ b/lisp/_prepare.el @@ -353,6 +353,11 @@ the `eask-start' execution.") ;; Just in case, but this should never happens! "latest")) +(defun eask-pkg-el () + "Return package description file if exists." + (let ((pkg-el (package--description-file default-directory))) + (when (file-readable-p pkg-el) pkg-el))) + ;; ;;; Flag @@ -657,14 +662,24 @@ Eask file in the workspace." (if eask-package-file (eask-error "Multiple definition of `package-file'") (setq eask-package-file (expand-file-name file)) - (if (file-exists-p eask-package-file) - (progn - (with-temp-buffer - (insert-file-contents eask-package-file) - (setq eask-package-desc (ignore-errors (package-buffer-info)))) - (unless eask-package-desc - (eask-warn "Failed to construct package-descriptor, lint the package-file `%s'" file))) - (eask-warn "Package-file seems to be missing `%s'" file)))) + (let* ((package-file-exists (file-exists-p eask-package-file)) + (def-point (if (eask-pkg-el) "-pkg.el file" "package-file")) + (target-file (cond ((eask-pkg-el) (expand-file-name (eask-pkg-el))) + (package-file-exists eask-package-file)))) + (unless package-file-exists + (eask-warn "Package-file seems to be missing `%s'" file)) + (when target-file + (with-temp-buffer + (insert-file-contents target-file) + (setq eask-package-desc (ignore-errors + (if (eask-pkg-el) + (package--read-pkg-desc 'dir) + (package-buffer-info))))) + (eask-msg (concat + (if eask-package-desc "✓ " "✗ ") + "Try constructing the package-descriptor (%s)... " + (if eask-package-desc "succeeded! " "failed!")) + (file-name-nondirectory target-file)))))) (defun eask-files (&rest patterns) "Set files patterns." @@ -1010,21 +1025,22 @@ Standard is, 0 (error), 1 (warning), 2 (info), 3 (log), 4 or above (debug)." "Return errors if required metadata is missing." (unless eask-package (eask-error "Missing metadata package; make sure you have create Eask-file with $ eask init!"))) -(defun eask--check-strings (fmt f p) +(defun eask--check-strings (fmt f p &rest args) "Test strings (F and P); then print FMT if not equal." - (unless (string= f p) (eask-warn fmt f p))) + (unless (string= f p) (apply #'eask-warn (append (list fmt f p) args)))) (defun eask--checker-metadata () "Report warnings if metadata doesn't match." - (when (and eask-package eask-package-desc) + (when-let* (((and eask-package eask-package-desc)) + (def-point (if (eask-pkg-el) "-pkg.el file" "package-file"))) (eask--check-strings - "Unmatch package name '%s'; it should be '%s'" + "Unmatched package name '%s'; it should be '%s'" (eask-package-name) (package-desc-name eask-package-desc)) (eask--check-strings - "Unmatch version '%s'; it should be '%s'" + "Unmatched version '%s'; it should be '%s'" (eask-package-version) (package-version-join (package-desc-version eask-package-desc))) (eask--check-strings - "Unmatch summary '%s'; it should be '%s'" + "Unmatched summary '%s'; it should be '%s'" (eask-package-description) (package-desc-summary eask-package-desc)) (let* ((dependencies (append eask-depends-on-emacs eask-depends-on)) (dependencies (mapcar #'car dependencies)) @@ -1034,10 +1050,10 @@ Standard is, 0 (error), 1 (warning), 2 (info), 3 (log), 4 or above (debug)." (requirements (mapcar (lambda (elm) (eask-2str elm)) requirements))) (dolist (req requirements) (unless (member req dependencies) - (eask-warn "Unmatch dependency '%s'; add (depends-on \"%s\") to Eask-file or consider removing it" req req))) + (eask-warn "Unmatched dependency '%s'; add (depends-on \"%s\") to Eask-file or consider removing it" req req))) (dolist (dep dependencies) (unless (member dep requirements) - (eask-warn "Unmatch dependency '%s'; add (%s \"VERSION\") to package-file or consider removing it" dep dep)))))) + (eask-warn "Unmatched dependency '%s'; add (%s \"VERSION\") to %s or consider removing it" dep dep def-point)))))) (add-hook 'eask-file-loaded-hook #'eask--checker-existence) (add-hook 'eask-file-loaded-hook #'eask--checker-metadata) diff --git a/lisp/core/info.el b/lisp/core/info.el index 3d78fd01..9f708421 100644 --- a/lisp/core/info.el +++ b/lisp/core/info.el @@ -49,7 +49,8 @@ (ansi-cyan (length eask-depends-on-dev))) (eask-msg (eask-package-description)) (when eask-package-desc - (eask-msg (ansi-cyan (eask--package-desc-url))) + (when-let ((url (eask--package-desc-url))) + (eask-msg (ansi-cyan url))) (when-let ((keywords (package-desc--keywords eask-package-desc))) (eask-msg "") (eask-msg "keywords: %s" (mapconcat #'identity keywords ", "))))