diff options
| author | Jimmy Yuen Ho Wong | 2021-03-13 16:29:27 +0000 |
|---|---|---|
| committer | Jimmy Yuen Ho Wong | 2021-03-13 16:29:27 +0000 |
| commit | f3ff593a849c6f9663bcba864d7de8ea587901aa (patch) | |
| tree | 83eef51a80b40ae9352a68dd3d17d6c5cb61d575 | |
| parent | ffa5f0397af87c7258f58082408281bf3a5a2deb (diff) | |
| download | emacs-f3ff593a849c6f9663bcba864d7de8ea587901aa.tar.gz emacs-f3ff593a849c6f9663bcba864d7de8ea587901aa.zip | |
Properly sort use-package-statistics-report
| -rw-r--r-- | lisp/use-package/use-package-core.el | 47 |
1 files changed, 38 insertions, 9 deletions
diff --git a/lisp/use-package/use-package-core.el b/lisp/use-package/use-package-core.el index 28bc5a50ed0..879e61edc4a 100644 --- a/lisp/use-package/use-package-core.el +++ b/lisp/use-package/use-package-core.el | |||
| @@ -998,11 +998,10 @@ If RECURSED is non-nil, recurse into sublists." | |||
| 998 | (defun use-package-statistics-last-event (package) | 998 | (defun use-package-statistics-last-event (package) |
| 999 | "Return the date when PACKAGE's status last changed. | 999 | "Return the date when PACKAGE's status last changed. |
| 1000 | The date is returned as a string." | 1000 | The date is returned as a string." |
| 1001 | (format-time-string "%Y-%m-%d %a %H:%M" | 1001 | (or (gethash :config package) |
| 1002 | (or (gethash :config package) | 1002 | (gethash :init package) |
| 1003 | (gethash :init package) | 1003 | (gethash :preface package) |
| 1004 | (gethash :preface package) | 1004 | (gethash :use-package package))) |
| 1005 | (gethash :use-package package)))) | ||
| 1006 | 1005 | ||
| 1007 | (defun use-package-statistics-time (package) | 1006 | (defun use-package-statistics-time (package) |
| 1008 | "Return the time is took for PACKAGE to load." | 1007 | "Return the time is took for PACKAGE to load." |
| @@ -1022,7 +1021,9 @@ The information is formatted in a way suitable for | |||
| 1022 | (vector | 1021 | (vector |
| 1023 | (symbol-name package) | 1022 | (symbol-name package) |
| 1024 | (use-package-statistics-status statistics) | 1023 | (use-package-statistics-status statistics) |
| 1025 | (use-package-statistics-last-event statistics) | 1024 | (format-time-string |
| 1025 | "%H:%M:%S.%6N" | ||
| 1026 | (use-package-statistics-last-event statistics)) | ||
| 1026 | (format "%.2f" (use-package-statistics-time statistics)))))) | 1027 | (format "%.2f" (use-package-statistics-time statistics)))))) |
| 1027 | 1028 | ||
| 1028 | (defun use-package-report () | 1029 | (defun use-package-report () |
| @@ -1042,15 +1043,43 @@ meaning: | |||
| 1042 | (tabulated-list-print) | 1043 | (tabulated-list-print) |
| 1043 | (display-buffer (current-buffer)))) | 1044 | (display-buffer (current-buffer)))) |
| 1044 | 1045 | ||
| 1046 | (defvar use-package-statistics-status-order | ||
| 1047 | '(("Declared" . 0) | ||
| 1048 | ("Prefaced" . 1) | ||
| 1049 | ("Initialized" . 2) | ||
| 1050 | ("Configured" . 3))) | ||
| 1051 | |||
| 1045 | (define-derived-mode use-package-statistics-mode tabulated-list-mode | 1052 | (define-derived-mode use-package-statistics-mode tabulated-list-mode |
| 1046 | "use-package statistics" | 1053 | "use-package statistics" |
| 1047 | "Show current statistics gathered about use-package declarations." | 1054 | "Show current statistics gathered about use-package declarations." |
| 1048 | (setq tabulated-list-format | 1055 | (setq tabulated-list-format |
| 1049 | ;; The sum of column width is 80 characters: | 1056 | ;; The sum of column width is 80 characters: |
| 1050 | [("Package" 25 t) | 1057 | [("Package" 25 t) |
| 1051 | ("Status" 13 t) | 1058 | ("Status" 13 |
| 1052 | ("Last Event" 23 t) | 1059 | (lambda (a b) |
| 1053 | ("Time" 10 t)]) | 1060 | (< (assoc-default |
| 1061 | (use-package-statistics-status | ||
| 1062 | (gethash (car a) use-package-statistics)) | ||
| 1063 | use-package-statistics-status-order) | ||
| 1064 | (assoc-default | ||
| 1065 | (use-package-statistics-status | ||
| 1066 | (gethash (car b) use-package-statistics)) | ||
| 1067 | use-package-statistics-status-order)))) | ||
| 1068 | ("Last Event" 23 | ||
| 1069 | (lambda (a b) | ||
| 1070 | (< (float-time | ||
| 1071 | (use-package-statistics-last-event | ||
| 1072 | (gethash (car a) use-package-statistics))) | ||
| 1073 | (float-time | ||
| 1074 | (use-package-statistics-last-event | ||
| 1075 | (gethash (car b) use-package-statistics)))))) | ||
| 1076 | ("Time" 10 | ||
| 1077 | (lambda (a b) | ||
| 1078 | (< (use-package-statistics-time | ||
| 1079 | (gethash (car a) use-package-statistics)) | ||
| 1080 | (use-package-statistics-time | ||
| 1081 | (gethash (car b) use-package-statistics)))))]) | ||
| 1082 | (setq tabulated-list-sort-key '("Time" . t)) | ||
| 1054 | (tabulated-list-init-header)) | 1083 | (tabulated-list-init-header)) |
| 1055 | 1084 | ||
| 1056 | (defun use-package-statistics-gather (keyword name after) | 1085 | (defun use-package-statistics-gather (keyword name after) |