summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Kaludercic <philipk@posteo.net>2022-12-25 11:18:51 +0100
committerPhilip Kaludercic <philipk@posteo.net>2022-12-25 11:21:01 +0100
commit9ab98cd42aa7ee7f23f05138beee1f69e7ce5fcc (patch)
tree92a4139705375b643155b1e5be742a608f41fbbf
parentdda011c78d1dc11306e2bf75d9ea451e1b8465a2 (diff)
downloademacs-9ab98cd42aa7ee7f23f05138beee1f69e7ce5fcc.tar.gz
emacs-9ab98cd42aa7ee7f23f05138beee1f69e7ce5fcc.tar.bz2
emacs-9ab98cd42aa7ee7f23f05138beee1f69e7ce5fcc.zip
Add heuristic to locate lisp code in source packages
* lisp/emacs-lisp/package-vc.el (package-vc--unpack): Check if a "lisp" directory exists and use that instead of PKG-DIR. (Bug#60155)
-rw-r--r--lisp/emacs-lisp/package-vc.el14
1 files changed, 14 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el
index bf6c822a2b5..549b6e95cdb 100644
--- a/lisp/emacs-lisp/package-vc.el
+++ b/lisp/emacs-lisp/package-vc.el
@@ -609,6 +609,20 @@ checkout. This overrides the `:branch' attribute in PKG-SPEC."
(error "There already exists a checkout for %s" name)))
(package-vc--clone pkg-desc pkg-spec pkg-dir rev)
+ ;; 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". If this
+ ;; directory exists and contains non-zero number of lisp files, we
+ ;; will use that instead of `pkg-dir'.
+ (when-let* (((null lisp-dir))
+ (dir (expand-file-name "lisp" 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.
+ (setq lisp-dir "lisp"))
(when lisp-dir
(push (cons :lisp-dir lisp-dir)
(package-desc-extras pkg-desc)))