branch: elpa/helm
commit d838d9c4a2f83ea04cbc7c9822e974d5bf9879c4
Author: Thierry Volpiatto <thie...@posteo.net>
Commit: Thierry Volpiatto <thie...@posteo.net>

    Add package.el compatibility fns for Emacs-28
    
    This will be removed once package.el moves on Elpa.
---
 helm-packages.el | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)

diff --git a/helm-packages.el b/helm-packages.el
index 73d9bc98cb..6c4caa6e9c 100644
--- a/helm-packages.el
+++ b/helm-packages.el
@@ -23,6 +23,63 @@
 (require 'package)
 (eval-when-compile (require 'helm-utils)) ; For 
with-helm-display-marked-candidates.
 
+;;; Compatibility with Emacs-29+
+;;  Needed by helm-packages.el waiting package.el moves on Elpa.
+;;  Slightly modified to fit with Emacs-28 (no package-vc).
+(when (< emacs-major-version 29)
+  (defun package--upgradeable-packages ()
+    ;; Initialize the package system to get the list of package
+    ;; symbols for completion.
+    (package--archives-initialize)
+    (mapcar
+     #'car
+     (seq-filter
+      (lambda (elt)
+        (or (let ((available
+                   (assq (car elt) package-archive-contents)))
+              (and available
+                   (version-list-<
+                    (package-desc-version (cadr elt))
+                    (package-desc-version (cadr available)))))))
+      package-alist)))
+
+  (defun package-upgrade (name)
+    "Upgrade package NAME if a newer version exists."
+    (let* ((package (if (symbolp name)
+                        name
+                      (intern name)))
+           (pkg-desc (cadr (assq package package-alist))))
+      ;; `pkg-desc' will be nil when the package is an "active built-in".
+      (when pkg-desc
+        (package-delete pkg-desc 'force 'dont-unselect))
+      (package-install package
+                       ;; An active built-in has never been "selected"
+                       ;; before.  Mark it as installed explicitly.
+                       (and pkg-desc 'dont-select))))
+
+  (defun package-recompile (pkg)
+    "Byte-compile package PKG again.
+PKG should be either a symbol, the package name, or a `package-desc'
+object."
+    (let ((pkg-desc (if (package-desc-p pkg)
+                        pkg
+                      (cadr (assq pkg package-alist)))))
+      ;; Delete the old .elc files to ensure that we don't inadvertently
+      ;; load them (in case they contain byte code/macros that are now
+      ;; invalid).
+      (dolist (elc (directory-files-recursively
+                    (package-desc-dir pkg-desc) "\\.elc\\'"))
+        (delete-file elc))
+      (package--compile pkg-desc)))
+
+  (defun package--dependencies (pkg)
+    "Return a list of all dependencies PKG has.
+This is done recursively."
+    ;; Can we have circular dependencies?  Assume "nope".
+    (when-let* ((desc (cadr (assq pkg package-archive-contents)))
+                (deps (mapcar #'car (package-desc-reqs desc))))
+      (delete-dups (apply #'nconc deps (mapcar #'package--dependencies 
deps))))))
+
 (defclass helm-packages-class (helm-source-in-buffer)
   ((coerce :initform #'helm-symbolify)
    (find-file-target :initform #'helm-packages-quit-an-find-file)

Reply via email to