From af88b00b19c155ce566757ccfa9ee2dbe03a705f Mon Sep 17 00:00:00 2001 From: Matt Armstrong Date: Wed, 30 Nov 2022 15:58:07 -0800 Subject: Refresh the package quickstart file in package-vc * lisp/emacs-lisp/package-vc.el (package-vc--unpack-1): Call `package--quickstart-maybe-refresh', just as `package-install-from-buffer' does. (bug#59728) --- lisp/emacs-lisp/package-vc.el | 1 + 1 file changed, 1 insertion(+) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el index 299964c6924..193d7c5b567 100644 --- a/lisp/emacs-lisp/package-vc.el +++ b/lisp/emacs-lisp/package-vc.el @@ -466,6 +466,7 @@ documentation and marking the package as installed." (package--save-selected-packages (cons (package-desc-name pkg-desc) package-selected-packages)) + (package--quickstart-maybe-refresh) ;; Confirm that the installation was successful (let ((main-file (package-vc--main-file pkg-desc))) -- cgit v1.2.3 From 5e8bc79f6b22cda99b522dbbdaa116ea62feb48e Mon Sep 17 00:00:00 2001 From: Philip Kaludercic Date: Fri, 9 Dec 2022 19:49:44 +0100 Subject: ; Fix reference in docstring to 'package-vc-install-from-checkout' * lisp/emacs-lisp/package-vc.el (package-vc-checkout): Fix reference. --- lisp/emacs-lisp/package-vc.el | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el index 193d7c5b567..80d268c2958 100644 --- a/lisp/emacs-lisp/package-vc.el +++ b/lisp/emacs-lisp/package-vc.el @@ -711,11 +711,11 @@ regular package, but it will not remove a VC package." (defun package-vc-checkout (pkg-desc directory &optional rev) "Clone the sources for PKG-DESC into DIRECTORY and visit that directory. Unlike `package-vc-install', this does not yet set up the package -for use with Emacs; use `package-vc-link-directory' for setting -the package up after this function finishes. -Optional argument REV means to clone a specific version of the -package; it defaults to the last version available from the -package's repository. If REV has the special value +for use with Emacs; use `package-vc-install-from-checkout' for +setting the package up after this function finishes. Optional +argument REV means to clone a specific version of the package; it +defaults to the last version available from the package's +repository. If REV has the special value `:last-release' (interactively, the prefix argument), that stands for the last released version of the package." (interactive -- cgit v1.2.3 From 357fe91996bc6015af002fe4259a3a61a5f32dbb Mon Sep 17 00:00:00 2001 From: Philip Kaludercic Date: Fri, 9 Dec 2022 19:54:25 +0100 Subject: Check if package already exists before installing from checkout * lisp/emacs-lisp/package-vc.el (package-vc-install-from-checkout): Copy check from 'package-vc--unpack'. --- lisp/emacs-lisp/package-vc.el | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el index 80d268c2958..cf9b98308f1 100644 --- a/lisp/emacs-lisp/package-vc.el +++ b/lisp/emacs-lisp/package-vc.el @@ -754,6 +754,10 @@ name from the base name of DIR." (package-vc--archives-initialize) (let* ((name (or name (file-name-base (directory-file-name dir)))) (pkg-dir (expand-file-name name package-user-dir))) + (when (file-exists-p pkg-dir) + (if (yes-or-no-p (format "Overwrite previous checkout for package `%s'?" name)) + (package--delete-directory pkg-dir) + (error "There already exists a checkout for %s" name))) (make-symbolic-link (expand-file-name dir) pkg-dir) (package-vc--unpack-1 (package-desc-create -- cgit v1.2.3 From 022ab1061b2a5ffebcc1a000386c1a568ac06e2f Mon Sep 17 00:00:00 2001 From: Philip Kaludercic Date: Sat, 10 Dec 2022 09:43:22 +0100 Subject: Ensure 'package-vc--main-file' always returns an existing file * lisp/emacs-lisp/package-vc.el (require): Explicitly require cl-lib. (package-vc--main-file): If the expected file name is missing, try and find the closest match. --- lisp/emacs-lisp/package-vc.el | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el index cf9b98308f1..b514afe288e 100644 --- a/lisp/emacs-lisp/package-vc.el +++ b/lisp/emacs-lisp/package-vc.el @@ -50,6 +50,7 @@ (eval-when-compile (require 'rx)) (eval-when-compile (require 'inline)) (eval-when-compile (require 'map)) +(eval-when-compile (require 'cl-lib)) (require 'package) (require 'lisp-mnt) (require 'vc) @@ -299,15 +300,34 @@ asynchronously." (defun package-vc--main-file (pkg-desc) "Return the name of the main file for PKG-DESC." (cl-assert (package-vc-p pkg-desc)) - (let ((pkg-spec (package-vc--desc->spec pkg-desc)) - (name (symbol-name (package-desc-name pkg-desc)))) - (or (plist-get pkg-spec :main-file) - (expand-file-name - (concat name ".el") - (file-name-concat - (or (package-desc-dir pkg-desc) - (expand-file-name name package-user-dir)) - (plist-get pkg-spec :lisp-dir)))))) + (let* ((pkg-spec (package-vc--desc->spec pkg-desc)) + (name (symbol-name (package-desc-name pkg-desc))) + (directory (file-name-concat + (or (package-desc-dir pkg-desc) + (expand-file-name name package-user-dir)) + (plist-get pkg-spec :lisp-dir))) + (file (or (plist-get pkg-spec :main-file) + (expand-file-name + (concat name ".el") + directory)))) + (if (file-exists-p file) file + ;; The following heuristic is only necessary when fetching a + ;; repository with URL that would break the above assumptions. + ;; Concrete example: https://github.com/sachac/waveform-el does + ;; not have a file waveform-el.el, but a file waveform.el, so we + ;; try and find the closest match. + (let ((distance most-positive-fixnum) (best nil)) + (dolist (alt (directory-files directory t "\\.el\\'" t)) + (let ((sd (string-distance file alt))) + (when (and (not (string-match-p (rx (or (: "-autoloads.el") + (: "-pkg.el")) + eos) + alt)) + (< sd distance)) + (when (< sd distance) + (setq distance (string-distance file alt) + best alt))))) + best)))) (defun package-vc--generate-description-file (pkg-desc pkg-file) "Generate a package description file for PKG-DESC and write it to PKG-FILE." -- cgit v1.2.3 From a8ee046fb500a527d3fa44e69a4bc178d0ae8406 Mon Sep 17 00:00:00 2001 From: Philip Kaludercic Date: Sat, 10 Dec 2022 09:47:42 +0100 Subject: Ensure 'package-vc--version' always returns a version * lisp/emacs-lisp/package-vc.el (package-vc--version): Return "0" even if the main file exists, but lacks version headers. --- lisp/emacs-lisp/package-vc.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el index b514afe288e..db54e0e130e 100644 --- a/lisp/emacs-lisp/package-vc.el +++ b/lisp/emacs-lisp/package-vc.el @@ -294,7 +294,8 @@ asynchronously." (insert-file-contents main-file) (package-strip-rcs-id (or (lm-header "package-version") - (lm-header "version")))) + (lm-header "version") + "0"))) "0")) (defun package-vc--main-file (pkg-desc) -- cgit v1.2.3