Function: package-dir-info
package-dir-info is a byte-compiled function defined in package.el.gz.
Signature
(package-dir-info)
Documentation
Find package information for a directory.
The return result is a package-desc.
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/package.el.gz
(defun package-dir-info ()
"Find package information for a directory.
The return result is a `package-desc'."
(cl-assert (derived-mode-p 'dired-mode))
(let* ((desc-file (package--description-file default-directory)))
(if (file-readable-p desc-file)
(with-temp-buffer
(insert-file-contents desc-file)
(package--read-pkg-desc 'dir))
(catch 'found
(let ((files (or (and (derived-mode-p 'dired-mode)
(dired-get-marked-files nil 'marked))
(directory-files default-directory t "\\.el\\'" t))))
;; We sort the file names by length, to ensure that we check
;; shorter file names first, as these are more likely to
;; contain the package metadata.
(dolist (file (sort files :key #'length))
;; The file may be a link to a nonexistent file; e.g., a
;; lock file.
(when (file-exists-p file)
(with-temp-buffer
(insert-file-contents file)
;; When we find the file with the data,
(when-let* ((info (ignore-errors (package-buffer-info))))
(setf (package-desc-kind info) 'dir)
(throw 'found info))))))
(error "No .el files with package headers in `%s'" default-directory)))))