summary refs log tree commit diff stats
path: root/tag-emacs/emacs.d/init.el
diff options
context:
space:
mode:
Diffstat (limited to 'tag-emacs/emacs.d/init.el')
-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