summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2022-12-11 09:34:03 +0800
committerPo Lu <luangruo@yahoo.com>2022-12-11 09:34:03 +0800
commit6d6ca47aba7b72d2a770d7ed01c849d3cc729e21 (patch)
treee8181f7188a3a74147549b7ba76ea9c3a696259c /lisp/emacs-lisp
parente08564432918aa87b49da58ac90bb43718424364 (diff)
parent44c5f3614973d8dc389ddcdc1b3f8ab1c809194d (diff)
downloademacs-6d6ca47aba7b72d2a770d7ed01c849d3cc729e21.tar.gz
emacs-6d6ca47aba7b72d2a770d7ed01c849d3cc729e21.tar.bz2
emacs-6d6ca47aba7b72d2a770d7ed01c849d3cc729e21.zip
Merge from origin/emacs-29
44c5f361497 ; Fix two byte-compiler warnings a8ee046fb50 Ensure 'package-vc--version' always returns a version 022ab1061b2 Ensure 'package-vc--main-file' always returns an existing... 357fe91996b Check if package already exists before installing from ch... 5e8bc79f6b2 ; Fix reference in docstring to 'package-vc-install-from-... af88b00b19c Refresh the package quickstart file in package-vc 5a092c8e461 ; * admin/notes/tree-sitter/starter-guide (Indent): Minor... ebef8905b0d Make indirect buffers use tree-sitter parsers of their ba... 8f53fa10d94 Fontify "this" as a keyword in c++-ts-mode (bug#59924) 8de8f1dc051 Add class_body indentation for typescript (bug#59680) 839341d7370 Make more granular defun-type-regexp (bug#59873) 8f49137c9bf Add dockerfile-ts-mode (Bug#59894) 1014bcc8e32 Fix fontification of method-invocations in js-ts-mode (bu... 7141920c6af Fix escape-sequence feature in typescript-ts-mode (bug#59... 4df35e3491c Improve fontification in csharp-ts-mode (bug#59909) 33a8415eb7e Use 'project--value-in-dir' for 'project-vc-include-untra... 594267395d5 Update Turkish Hello 940d9070e97 Support newer glib versions (Bug#59061) 0bd26abf7fb ; * doc/misc/use-package.texi: Fix @file. bcf235acd58 Merge branch 'emacs-29' of git.savannah.gnu.org:/srv/git/... 2ea7a357fd1 ; * doc/misc/use-package.texi: Fix @acronym. d268ab1c5d7 Bring back the project--value-in-dir logic
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/package-vc.el56
1 files changed, 41 insertions, 15 deletions
diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el
index 299964c6924..db54e0e130e 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)
@@ -293,21 +294,41 @@ 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)
"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."
@@ -466,6 +487,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)))
@@ -710,11 +732,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
@@ -753,6 +775,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