Remove unused variable, fix default values, add autoload

This commit is contained in:
Lucien Cartier-Tilet 2021-04-29 21:56:53 +02:00
parent 0974464af2
commit 4f34968363
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA

View File

@ -46,35 +46,30 @@
; Custom variables ;;;;;;;;;;;;;;;;;;;; ; Custom variables ;;;;;;;;;;;;;;;;;;;;
(defcustom eshell-info-banner-max-length-partition 13 (defcustom eshell-info-banner-shorten-path-from 7
"Maximum length of a partitions ruler." "From which length should a path be shortened?"
:group 'eshell-info-banner :group 'eshell-info-banner
:type 'integer) :type 'integer)
(defcustom eshell-info-banner-percentage-critical 120
"When a percentage becomes critical."
:group 'eshell-info-banner
:type 'float)
(defcustom eshell-info-banner-percentage-warning 75
"When to warn about a percentage."
:group 'eshell-info-banner
:type 'float)
(defcustom eshell-info-banner-progress-bar-char "="
"Character to fill the progress bars with."
:group 'eshell-info-banner
:type 'char)
(defcustom eshell-info-banner-width 80 (defcustom eshell-info-banner-width 80
"Width of the info banner to be shown in Eshell." "Width of the info banner to be shown in Eshell."
:group 'eshell-info-banner :group 'eshell-info-banner
:type 'integer) :type 'integer)
(defcustom eshell-info-banner-shorten-path-from 7 (defcustom eshell-info-banner-progress-bar-char "="
"From which length should a path be shortened?" "Character to fill the progress bars with."
:group 'eshell-info-banner :group 'eshell-info-banner
:type 'integer) :type 'char)
(defcustom eshell-info-banner-warning-percentage 75
"When to warn about a percentage."
:group 'eshell-info-banner
:type 'float)
(defcustom eshell-info-banner-critical-percentage 90
"When a percentage becomes critical."
:group 'eshell-info-banner
:type 'float)
; Faces ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Faces ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -180,16 +175,15 @@ the left side of the banner."
(len (max (length path) len))) (len (max (length path) len)))
(eshell-info-banner--get-longest-path (cdr partitions) len))))) (eshell-info-banner--get-longest-path (cdr partitions) len)))))
;; FIXME: Theres apparently an issue here selecting faces
(defun eshell-info-banner--get-color-percentage (percentage) (defun eshell-info-banner--get-color-percentage (percentage)
"Display a `PERCENTAGE' with its according face." "Display a `PERCENTAGE' with its according face."
(let ((percentage (if (stringp percentage) (let ((percentage (if (stringp percentage)
(string-to-number percentage) (string-to-number percentage)
percentage))) percentage)))
(cond (cond
((>= percentage eshell-info-banner-percentage-critical) ((>= percentage eshell-info-banner-critical-percentage)
'eshell-info-banner-critical-face) 'eshell-info-banner-critical-face)
((>= percentage eshell-info-banner-percentage-warning) ((>= percentage eshell-info-banner-warning-percentage)
'eshell-info-banner-warning-face) 'eshell-info-banner-warning-face)
(t 'eshell-info-banner-normal-face)))) (t 'eshell-info-banner-normal-face))))
@ -261,6 +255,8 @@ See also `eshell-info-banner--display-memory'."
(number-to-string percentage) (number-to-string percentage)
:inherit (eshell-info-banner--get-color-percentage percentage)))))) :inherit (eshell-info-banner--get-color-percentage percentage))))))
; Public functions ;;;;;;;;;;;;;;;;;;;;
;;;###autoload ;;;###autoload
(defun eshell-info-banner () (defun eshell-info-banner ()
"Banner for Eshell displaying system information." "Banner for Eshell displaying system information."
@ -325,11 +321,11 @@ See also `eshell-info-banner--display-memory'."
"\n") "\n")
(format "\n%s\n" (s-repeat tot-width eshell-info-banner-progress-bar-char))))) (format "\n%s\n" (s-repeat tot-width eshell-info-banner-progress-bar-char)))))
;;;###autoload
(defun eshell-info-banner-update-banner () (defun eshell-info-banner-update-banner ()
"Update the Eshell banner." "Update the Eshell banner."
(setq eshell-banner-message (eshell-info-banner))) (setq eshell-banner-message (eshell-info-banner)))
(provide 'eshell-info-banner) (provide 'eshell-info-banner)
;;; eshell-info-banner.el ends here ;;; eshell-info-banner.el ends here