Compare commits

..

6 Commits
0.8.8 ... main

Author SHA1 Message Date
SqrtMinusOne 2f4e59ea7a Add new variables to the README 2022-07-28 12:06:06 +02:00
SqrtMinusOne 987e69a662 Add an option to exclude some partitions 2022-07-28 12:06:06 +02:00
SqrtMinusOne 6b464b1b73 Add an option to filter duplicate partitions 2022-07-28 12:06:06 +02:00
Lucien Cartier-Tilet b7f2bfc013
v0.8.8 2022-05-31 11:40:22 +02:00
Lucien Cartier-Tilet fcc88df86a
Add CI with Github Actions
Check for compatibility with all version of Emacs since Emacs 25.1

Add Cask file for managing dependencies in CI

Add badge in README for CI
2022-05-31 11:40:22 +02:00
Lucien Cartier-Tilet 4ffaf329db
Fix erroneous require 2022-05-31 11:40:12 +02:00
2 changed files with 61 additions and 9 deletions

View File

@ -109,6 +109,15 @@ A couple of variables can be edited by the user in order to configure
set its value to ~("/dev" "zroot")~.
Default value: ~("/dev")~
- ~eshell-info-banner-filter-duplicate-partitions~ :: Try to filter
out duplicate partitions. Two partitions are considered duplicate if
they have the same size and amount of space used.
Default value: ~nil~
- ~eshell-info-banner-exclude-partitions~ :: List of pattens to exclude
from the partition list.
Default value: ~nil~
- ~eshell-info-banner-shorten-path-from~ :: Maximum length of the mount
path of a partition before it gets abbreviated. Set it to ridiculous
numbers in order to disable it (something like ~1000~ should be more

View File

@ -139,6 +139,21 @@
:group 'eshell-info-banner
:type 'list)
(defcustom eshell-info-banner-filter-duplicate-partitions nil
"Whether to filter duplicate partitions.
Two partitions are considered duplicate if they have the same
size and amount of space used."
:group 'eshell-info-banner
:type 'boolean)
(defcustom eshell-info-banner-exclude-partitions nil
"List of patterns to exclude from the partition list.
Patterns are matched against the partition name with
`string-match-p'."
:group 'eshell-info-banner
:type '(repeat string))
(defmacro eshell-info-banner--executable-find (program)
"Find PROGRAM executable, possibly on a remote machine.
@ -417,24 +432,52 @@ Return detected partitions as a list of structs. See
chosen. Relies on the `df' command."
(eshell-info-banner--get-mounted-partitions-df 8))
(defun eshell-info-banner--get-mounted-partitions ()
(defun eshell-info-banner--get-mounted-partitions-1 ()
"Detect mounted partitions on the system.
Return detected partitions as a list of structs."
(if eshell-info-banner-use-duf
(eshell-info-banner--get-mounted-partitions-duf)
(pcase system-type
((or 'gnu 'gnu/linux 'gnu/kfreebsd 'berkeley-unix)
(eshell-info-banner--get-mounted-partitions-gnu))
((or 'ms-dos 'windows-nt 'cygwin)
(eshell-info-banner--get-mounted-partitions-windows))
('darwin
(eshell-info-banner--get-mounted-partitions-darwin))
(other
(progn
((or 'gnu 'gnu/linux 'gnu/kfreebsd 'berkeley-unix)
(eshell-info-banner--get-mounted-partitions-gnu))
((or 'ms-dos 'windows-nt 'cygwin)
(eshell-info-banner--get-mounted-partitions-windows))
('darwin
(eshell-info-banner--get-mounted-partitions-darwin))
(other
(progn
(warn "Partition detection for %s not yet supported." other)
nil)))))
(defun eshell-info-banner--get-mounted-partitions ()
"Detect mounted partitions on the system.
Take `eshell-info-banner-filter-duplicate-partitions' and
`eshell-info-banner-exclude-partitions' into account."
(let ((partitions (eshell-info-banner--get-mounted-partitions-1)))
(when eshell-info-banner-filter-duplicate-partitions
(setq partitions
(cl-loop for partition in partitions
with used = nil
for signature =
(format "%d-%d"
(eshell-info-banner--mounted-partitions-size partition)
(eshell-info-banner--mounted-partitions-used partition))
unless (member signature used)
collect partition and do (push signature used))))
(when eshell-info-banner-exclude-partitions
(setq partitions
(seq-filter (lambda (partition)
(let ((path (eshell-info-banner--mounted-partitions-path
partition)))
(not (seq-some
(lambda (pattern)
(string-match-p pattern path))
eshell-info-banner-exclude-partitions))))
partitions)))
partitions))
(defun eshell-info-banner--partition-to-string (partition text-padding bar-length)
"Display a progress bar showing how full a PARTITION is.