[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/package+vc f5bb6b0131 1/3: Allow updating source packages
From: |
Philip Kaludercic |
Subject: |
feature/package+vc f5bb6b0131 1/3: Allow updating source packages |
Date: |
Thu, 11 Aug 2022 08:08:05 -0400 (EDT) |
branch: feature/package+vc
commit f5bb6b01318fe3a21493992e94908cf685e9b26b
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>
Allow updating source packages
* lisp/emacs-lisp/package-vc.el (package-vc-update): Add new function.
* lisp/emacs-lisp/package.el (package-update): Use 'package-vc-update'.
---
lisp/emacs-lisp/package-vc.el | 6 ++++++
lisp/emacs-lisp/package.el | 15 ++++++++++-----
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el
index 0f5ee4305a..04821d43c4 100644
--- a/lisp/emacs-lisp/package-vc.el
+++ b/lisp/emacs-lisp/package-vc.el
@@ -227,6 +227,12 @@ The output is written out into PKG-FILE."
t))))
package-archive-contents))
+(defun package-vc-update (pkg-desc)
+ "Attempt to update the packager PKG-DESC."
+ (let ((default-directory (package-desc-dir pkg-desc)))
+ (with-demoted-errors "Error during package update: %S"
+ (vc-pull))))
+
(defun package-vc-fetch (name-or-url &optional name rev)
"Fetch the source of NAME-OR-URL.
If NAME-OR-URL is a URL, then the package will be downloaded from
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 1321c3728e..1ee39f8752 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -2194,17 +2194,22 @@ to install it but still mark it as selected."
(message "Package `%s' installed." name))
(message "`%s' is already installed" name))))
+(declare-function package-vc-update "package-vc" (pkg))
+
;;;###autoload
(defun package-update (name)
"Update package NAME if a newer version exists."
(interactive
(list (completing-read
"Update package: " (package--updateable-packages) nil t)))
- (let ((package (if (symbolp name)
- name
- (intern name))))
- (package-delete (cadr (assq package package-alist)) 'force)
- (package-install package 'dont-select)))
+ (let* ((package (if (symbolp name)
+ name
+ (intern name)))
+ (pkg-desc (cadr (assq package package-alist))))
+ (if (eq (package-desc-kind pkg-desc) 'vc)
+ (package-vc-update pkg-desc)
+ (package-delete pkg-desc 'force)
+ (package-install package 'dont-select))))
(defun package--updateable-packages ()
;; Initialize the package system to get the list of package