diff options
Diffstat (limited to 'content/post/emacs-package-archive-statistics.md')
-rw-r--r-- | content/post/emacs-package-archive-statistics.md | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/content/post/emacs-package-archive-statistics.md b/content/post/emacs-package-archive-statistics.md index 9a8e8bf..43d0969 100644 --- a/content/post/emacs-package-archive-statistics.md +++ b/content/post/emacs-package-archive-statistics.md @@ -10,7 +10,7 @@ I use [cask][] for managing the dependencies of my Emacs configuration. Whenever I opened my `Cask` file, I wondered if I really was using all the sources I had defined: -```elisp +```lisp (source gnu) (source marmalade) (source melpa) @@ -44,7 +44,7 @@ decided to try to figure out how to generate some usage statistics. I found [how to get a list of installed packages][], but that just gives a list: -```elisp +```lisp (ace-jump-mode ag auto-compile auto-indent-mode autopair ...) ``` @@ -52,7 +52,7 @@ I needed to get more information about those packages. I looked at where `list-packages` gets that information from. It seems that `package-archive-contents` is a list of cons cells: -```elisp +```lisp (org-plus-contrib . [(20140714) nil "Outline-based notes management and organizer" tar "org"]) @@ -62,7 +62,7 @@ Then created a function to loop over the contents of `package-activated-list`, retrieving the corresponding contents of `package-archive-contents`: -```elisp +```lisp (defun package-list-installed () (loop for pkg in package-activated-list collect (assq pkg package-archive-contents))) @@ -74,7 +74,7 @@ There are some helper functions in package.el such as needed. I happened to be using a pretest version of Emacs at the time and didn't know that it's not in 24.3, so I just made sure it was defined: -```elisp +```lisp (if (not (fboundp #'package-desc-archive)) (defsubst package-desc-archive (desc) (aref desc (1- (length desc))))) @@ -89,7 +89,7 @@ To generate a list of statistics, I just needed to loop over the installed packages from `package-list-installed` and update a count for each archive: -```elisp +```lisp (defun package-archive-stats () (let ((archives (makehash)) (assoc '())) @@ -105,7 +105,7 @@ for each archive: Running this gives a list of cons cells: -```elisp +```lisp (("gnu" . 0) ("org" . 1) ("melpa-stable" . 2) @@ -116,7 +116,7 @@ Running this gives a list of cons cells: I wrapped it in an interactive function so that I could check the numbers quickly: -```elisp +```lisp (defun package-show-archive-stats () (interactive) (message "%s" (package-archive-stats))) @@ -126,7 +126,7 @@ With that, I removed `(source gnu)` from my `Cask` file. Now I had another question. What package was installed from [marmalade][]? In the lisp fashion, I created yet another function: -```elisp +```lisp (defun package-show-installed-from-archive (archive) (interactive (list (helm-comp-read "Archive: " (mapcar #'car package-archives) :must-match t))) @@ -142,7 +142,7 @@ the lisp fashion, I created yet another function: Running this with the argument `"marmalade"` gives: -```elisp +```lisp (php-extras) ``` |