all repos — nixfiles @ d81bf7b2b8f80b4d646a651b1218c8b18a2d9725

System and user configuration, managed by nix and home-manager

Emacs: Create package archive query functions Count packages installed from each archive Show installed packages from an archive

Alan Pearce
commit

d81bf7b2b8f80b4d646a651b1218c8b18a2d9725

parent

87fb552d62b2135fc6b11e1b073f0a901b639849

1 file changed, 30 insertions(+), 0 deletions(-)

jump to
M tag-emacs/emacs.d/init.eltag-emacs/emacs.d/init.el
@@ -55,6 +55,36 @@ :defer t
: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