;;; -*- lexical-binding: t -*- ;; ;; this file: ;; https://dataswamp.org/~incal/emacs-init/meta.el (require 'cl-lib) (defun meta--count-list (l) (cl-loop with res with done for e in l do (unless (member e done) (push (list (cl-count e l :test #'equal) e) res) (push e done)) finally return (cl-sort res #'>= :key #'car))) (defun meta--result-list (l) (cl-loop with biggest = (length (number-to-string (caar l))) with num-len = (length (number-to-string (length l))) with longest = (apply #'max (cl-mapcar (lambda (e) (length (cadr e))) l)) for (n lib) in l for i from 1 for str = (concat str (format (concat (format "%%%dd. " num-len) (format "%%-%ds " longest) (format "%%%dd" biggest) "\n") i lib n)) finally (insert "\n" str))) (defun meta--funs (&optional n pred label) (or n (setq n 20)) (or pred (setq pred #'functionp)) (or label (setq label (symbol-name pred))) (let ((num 0) (libs) (str) (dash) (par)) (mapatoms (lambda (e) (when (funcall pred e) (setq str (symbol-name e)) (setq dash (string-match "-" str)) (setq par (string-match "(" str)) (unless par (cl-incf num) (when dash (push (substring str 0 dash) libs)))))) (with-help-window "*meta*" (insert (format "%s: %d\n" label num)) (let* ((clst (meta--count-list libs)) (len (length clst))) (meta--result-list (cl-subseq clst 0 (min n (1- len)))))))) ;; (meta--funs 10 nil "functions") ;; (meta--funs nil nil "functions") ;; (meta--funs 100 nil "functions") ;; (meta--funs 1000 nil "functions") ;; (meta--funs 10 #'boundp "variables") ;; (meta--funs nil #'boundp "variables") ;; (meta--funs 100 #'boundp "variables") ;; (meta--funs 1000 #'boundp "variables") ;; (meta--funs 10 #'facep "faces") ;; (meta--funs nil #'facep "faces") ;; (meta--funs 100 #'facep "faces") ;; (meta--funs 1000 #'facep "faces") (provide 'meta)