From a1e52ede10f4d661f5d533aa5ef5d5805624658c Mon Sep 17 00:00:00 2001 From: Daniel Nagy Date: Mon, 4 Apr 2022 21:03:47 +0200 Subject: [PATCH] doc: Updates --- tokei.el | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tokei.el b/tokei.el index 5417c16..228ccb7 100644 --- a/tokei.el +++ b/tokei.el @@ -47,16 +47,17 @@ (defvar tokei-program "tokei" "Path to the tokei program.") (defun tokei--data () + "Return newly created tokei data for this directory." (json-parse-string (with-temp-buffer - (if (zerop (call-process tokei-program nil t nil "--output=json" "--sort" "code")) + (if (zerop (call-process tokei-program nil t nil "--output=json" )) (buffer-string) "")) :object-type 'alist :array-type 'list)) (defun tokei--sort-predicate (elem1 elem2) - "A predicate to compare elem1 and elemt2 by num of code and then name." + "A predicate to compare ELEM1 and ELEM2 by num of code and then name." (let ((numcode1 (or (alist-get 'code elem1) (alist-get 'code (alist-get 'stats elem1)))) (numcode2 (or (alist-get 'code elem2) (alist-get 'code (alist-get 'stats elem2)))) (name1 (or (alist-get 'name elem1) (car elem1))) @@ -66,9 +67,13 @@ (> numcode1 numcode2)))) (cl-defun tokei--get-sorted (&optional (data tokei-data)) + "Sort the provided tokei DATA." (sort (copy-sequence data) #'tokei--sort-predicate)) (defun tokei--formatted-stats (code comments) + "Format one entry. + +Takes CODE and COMMENTS entries." (string-join (list (propertize (number-to-string code) 'face 'tokei-num-code-face) @@ -76,6 +81,9 @@ " ยท ")) (defun tokei--get-formatted-files (json) + "Retrieve multiple formatted entries. + +Data is provided via the JSON argument" (cl-loop for s in (sort (copy-sequence (alist-get 'reports json)) #'tokei--sort-predicate)