Function: package-vc--checkout-dir

package-vc--checkout-dir is a byte-compiled function defined in package-vc.el.gz.

Signature

(package-vc--checkout-dir PKG-DESC &optional LISP-DIR)

Documentation

Return the directory of the actual VC checkout for PKG-DESC.

For most packages this is the same as package-desc-dir, unless the package has been installed via package-vc-install-from-checkout. In that case the package redirects to the actual VC checkout. If the optional LISP-DIR argument is non-nil, then check if a related package specification has a :lisp-dir field to indicate that Lisp files are located in a sub directory of the checkout, or the checkout has a sub directory named "lisp" or "src" that contains .el files and return that instead.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/package-vc.el.gz
(defun package-vc--checkout-dir (pkg-desc &optional lisp-dir)
  "Return the directory of the actual VC checkout for PKG-DESC.
For most packages this is the same as `package-desc-dir', unless the
package has been installed via `package-vc-install-from-checkout'.  In
that case the package redirects to the actual VC checkout.  If the
optional LISP-DIR argument is non-nil, then check if a related package
specification has a `:lisp-dir' field to indicate that Lisp files are
located in a sub directory of the checkout, or the checkout has a sub
directory named \"lisp\" or \"src\" that contains .el files and return
that instead."
  (let* ((pkg-spec (package-vc--desc->spec pkg-desc))
         (pkg-dir (or (alist-get :vc-dir (package-desc-extras pkg-desc))
                      (package-desc-dir pkg-desc))))
    (expand-file-name
     (or (and lisp-dir
              (or (plist-get pkg-spec :lisp-dir)
                  ;; When nothing is specified about a `lisp-dir', then
                  ;; should heuristically check if there is a
                  ;; sub-directory with lisp files.  These are
                  ;; conventionally just called "lisp" or "src".  If
                  ;; this directory exists and contains non-zero number
                  ;; of lisp files, we will use that instead of
                  ;; `pkg-dir'.
                  (catch 'done
                    (dolist (name '("lisp" "src"))
                      (when-let* ((dir (expand-file-name name pkg-dir))
                                  ((file-directory-p dir))
                                  ((directory-files
                                    dir nil "\\`[^.].+\\.el\\'" t 1)))
                        ;; We won't use `dir', since dir is an absolute
                        ;; path and we don't want `lisp-dir' to depend
                        ;; on the current location of the package
                        ;; installation, ie. to break if moved around
                        ;; the file system or between installations.
                        (throw 'done name))))))
         ".")
     pkg-dir)))