From 987e69a66276ca057798896c606e5c5d5fb9ee5c Mon Sep 17 00:00:00 2001 From: SqrtMinusOne Date: Thu, 21 Jul 2022 21:44:54 +0300 Subject: [PATCH] Add an option to exclude some partitions --- eshell-info-banner.el | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/eshell-info-banner.el b/eshell-info-banner.el index 9e66156..eda362c 100644 --- a/eshell-info-banner.el +++ b/eshell-info-banner.el @@ -147,6 +147,14 @@ 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. This is a wrapper around `executable-find' in order to avoid @@ -445,8 +453,8 @@ Return detected partitions as a list of structs." (defun eshell-info-banner--get-mounted-partitions () "Detect mounted partitions on the system. -Take `eshell-info-banner-filter-duplicate-partitions' into -account." +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 @@ -458,6 +466,16 @@ account." (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)