summary refs log tree commit diff stats
path: root/tag-emacs
diff options
context:
space:
mode:
authorAlan Pearce2014-07-11 22:45:56 +0100
committerAlan Pearce2014-07-11 22:45:56 +0100
commitd81bf7b2b8f80b4d646a651b1218c8b18a2d9725 (patch)
treeb0c13f10e53eab753d5375bb92dd4fbeaa9bcb4c /tag-emacs
parent87fb552d62b2135fc6b11e1b073f0a901b639849 (diff)
downloadnixfiles-d81bf7b2b8f80b4d646a651b1218c8b18a2d9725.tar.lz
nixfiles-d81bf7b2b8f80b4d646a651b1218c8b18a2d9725.tar.zst
nixfiles-d81bf7b2b8f80b4d646a651b1218c8b18a2d9725.zip
Emacs: Create package archive query functions
Count packages installed from each archive
Show installed packages from an archive
Diffstat (limited to 'tag-emacs')
-rw-r--r--tag-emacs/emacs.d/init.el30
1 files changed, 30 insertions, 0 deletions
diff --git a/tag-emacs/emacs.d/init.el b/tag-emacs/emacs.d/init.el
index b14fd021..e044680f 100644
--- a/tag-emacs/emacs.d/init.el
+++ b/tag-emacs/emacs.d/init.el
@@ -55,6 +55,36 @@
   :config (progn
             (setq paradox-automatically-star t)))
 
+(defun package-list-installed ()
+  (loop for pkg in package-activated-list
+        collect (cadr (assq pkg package-archive-contents))))
+
+(defun package-archive-stats ()
+  (let ((archives (makehash))
+        (assoc '()))
+    (dolist (arc package-archives)
+      (puthash (car arc) 0 archives))
+    (maphash (lambda (k v)
+               (setq assoc (cons (cons k v) assoc)))
+             (dolist (pkg (package-list-installed) archives)
+               (let ((pkg-arc (package-desc-archive pkg)))
+                 (incf (gethash pkg-arc archives)))))
+    assoc))
+
+(defun package-show-installed-from-archive (archive)
+  (interactive (list (helm-comp-read "Archive: " (mapcar #'car package-archives)
+                                      :must-match t)))
+  (let ((from-arc (mapcar #'package-desc-name
+                          (--filter (equalp (package-desc-archive it) archive)
+                                    (package-list-installed)))))
+    (if (called-interactively-p)
+        (message "%s" from-arc)
+      from-arc)))
+
+(defun package-show-archive-stats ()
+  (interactive)
+  (message "%s" (package-archive-stats)))
+
 ;;;; Style
 
 (req-package linum