Skip to content

Instantly share code, notes, and snippets.

@bmag
Forked from RockyRoad29/README.org
Created February 19, 2017 18:48
Show Gist options
  • Save bmag/4b93461f2b2388f4241d64a17f86948b to your computer and use it in GitHub Desktop.
Save bmag/4b93461f2b2388f4241d64a17f86948b to your computer and use it in GitHub Desktop.
Emacs loaded packages exploration tools
;;; lpkg-explorer.el --- Emacs loaded packages exploration tools -*- lexical-binding: t; -*-
;; Copyright (C) 2017 Michelle Baert
;; Author: Michelle Baert https://gist.github.com/RockyRoad29
;; Keywords: maint
;; ---------------------------------------------------------------
;; These functions are designed basically for use in
;; a lisp interaction session, where more variants
;; may easily be tailored for your needs.
;;
;; My main purpose here is to detect potential org-mode conflicts
;; between built-in (typically older) and user local versions.
(defun tmp:lpkg-init()
(with-current-buffer (get-buffer-create "*loaded-packages*")
(erase-buffer)
;(pop-to-buffer (current-buffer) )
;; extract data from builtin var 'load-history
(setq-local tmp:lpkg-all-files
(seq-filter #'stringp
(mapcar #'car load-history)
))
(insert "* Live Packages Exploration\n\n")
(insert (format "%s total packages currently loaded\n\n"
(length tmp:lpkg-all-files)))
)
)
(defun tmp:lpkg-print-matching (regexp)
(with-current-buffer (get-buffer-create "*loaded-packages*")
;; (pop-to-buffer (current-buffer) )
(goto-char (point-max))
(let (
(l1 (seq-filter
(lambda (x) (and x
(string-match regexp x)))
tmp:lpkg-all-files))
)
(insert (format "\n** %d packages matching %s (%d%%)\n"
(length l1)
(prin1-to-string regexp)
(/ (* 100 (length l1)) (length tmp:lpkg-all-files))))
(dolist (x l1) (insert (format " - %s\n" x)))
)))
(defun tmp:lpkg-list-features ()
(with-current-buffer (get-buffer-create "*loaded-packages*")
(goto-char (point-max))
(let (
)
(insert (format "\n** %d features currently loaded\n"
(length features)
))
(dolist (x features)
(insert (format " - %s: %s\n" x (locate-library (symbol-name x))
)))
))
)
;; ===============================================
;; Now my checks
;; 1. load packages by name
(require 'ob)
(require 'org)
(require 'org-agenda)
(require 'org-mime)
;; 2. check where they came from
(tmp:lpkg-init)
(pop-to-buffer "*loaded-packages*" )
(tmp:lpkg-print-matching "/org")
(tmp:lpkg-print-matching "/ob")
(tmp:lpkg-print-matching "/use")
;; NOTE I then found about load-library and wrote #'tmp:lpkg-list-features
;; Using #'occur on the target buffer may answer more questions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment