Merge pull request #8 from juergenhoetzel/leverage-reduce
Leverage -reduce-from function
This commit is contained in:
		
						commit
						7ddb41ed3e
					
				@ -173,20 +173,14 @@ Return detected partitions as a list of structs."
 | 
				
			|||||||
                            (string-trim-left percent (regexp-quote "%")))))))
 | 
					                            (string-trim-left percent (regexp-quote "%")))))))
 | 
				
			||||||
           partitions)))
 | 
					           partitions)))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(defun eshell-info-banner--get-longest-path (partitions &optional len)
 | 
					(defun eshell-info-banner--get-longest-path (partitions)
 | 
				
			||||||
  "Find the length of the longest partition path in `PARTITIONS'.
 | 
					  "Return the length of the longest partition path in `PARTITIONS'.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
The variable `LEN' should only be used internally and represents
 | 
					The returned value is in any case greater than `eshell-info-banner--min-length-left'."
 | 
				
			||||||
the longest path so far, or the minimum length of text present on
 | 
					  (-reduce-from (lambda (len partition)
 | 
				
			||||||
the left side of the banner."
 | 
							  (max len (length (eshell-info-banner--mounted-partitions-path partition))))
 | 
				
			||||||
  (let ((len (if (null len)
 | 
					 | 
				
			||||||
		eshell-info-banner--min-length-left
 | 
							eshell-info-banner--min-length-left
 | 
				
			||||||
               len)))
 | 
							partitions))
 | 
				
			||||||
    (if (null partitions)
 | 
					 | 
				
			||||||
        len
 | 
					 | 
				
			||||||
      (let* ((path (eshell-info-banner--mounted-partitions-path (car partitions)))
 | 
					 | 
				
			||||||
             (len (max (length path) len)))
 | 
					 | 
				
			||||||
        (eshell-info-banner--get-longest-path (cdr partitions) len)))))
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
(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."
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user