Function: keyfreq-list
keyfreq-list is a natively compiled function defined in keyfreq.el.
Signature
(keyfreq-list TABLE &optional REVERSE LIMIT)
Documentation
Return a cons which car is sum of times any command was used and cdr is a list of (command . count) pairs.
If REVERSE is nil, sort it starting from the most used command;
if it is no-sort the list is not sorted; if it is non-nil and
not no-sort, sort it from the least used commands. If LIMIT is
a positive number, only commands which were used more then LIMIT
times will be added. If it is a negative number, only commands
which were used less then -LIMIT times will be added.
Source Code
;; Defined in /nix/store/vs0cnjcny583s3d1i80ya8g63h6xkwrn-emacs-packages-deps/share/emacs/site-lisp/elpa/keyfreq-20231107.106/keyfreq.el
(defun keyfreq-list (table &optional reverse limit)
"Return a cons which car is sum of times any command was used
and cdr is a list of (command . count) pairs.
If REVERSE is nil, sort it starting from the most used command;
if it is `no-sort' the list is not sorted; if it is non-nil and
not `no-sort', sort it from the least used commands. If LIMIT is
a positive number, only commands which were used more then LIMIT
times will be added. If it is a negative number, only commands
which were used less then -LIMIT times will be added."
(let (l (sum 0))
(maphash
(cond
((or (not (numberp limit)) (= limit 0))
(lambda (k v) (setq l (cons (cons k v) l) sum (+ sum v))))
((= limit -1) (lambda (k v) (setq sum (+ sum v))))
((< limit 0)
(setq limit (- limit))
(lambda (k v) (setq sum (+ sum v))
(if (< v limit) (setq l (cons (cons k v) l)))))
(t
(lambda (k v) (setq sum (+ sum v))
(if (> v limit) (setq l (cons (cons k v) l))))))
table)
(cons sum
(cond
((equal reverse 'no-sort) l)
(reverse (sort l (lambda (a b) (< (cdr a) (cdr b)))))
(t (sort l (lambda (a b) (> (cdr a) (cdr b)))))))))