From d81bf7b2b8f80b4d646a651b1218c8b18a2d9725 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Fri, 11 Jul 2014 22:45:56 +0100 Subject: Emacs: Create package archive query functions Count packages installed from each archive Show installed packages from an archive --- tag-emacs/emacs.d/init.el | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'tag-emacs') 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 -- cgit 1.4.1