From 117b8238bd9175f2af88347b1a516b38c9d4adce Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sun, 7 Feb 2016 21:23:15 +0000 Subject: Offer a spinner-make-progress-bar function --- spinner.el | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'spinner.el') diff --git a/spinner.el b/spinner.el index ec0a64f..df59e10 100644 --- a/spinner.el +++ b/spinner.el @@ -3,7 +3,7 @@ ;; Copyright (C) 2015 Free Software Foundation, Inc. ;; Author: Artur Malabarba -;; Version: 1.5 +;; Version: 1.6 ;; URL: https://github.com/Malabarba/spinner.el ;; Keywords: processes mode-line @@ -123,6 +123,18 @@ Each car is a symbol identifying the spinner, and each cdr is a vector, the spinner itself.") +(defun spinner-make-progress-bar (width &optional char) + "Return a vector of strings of the given WIDTH. +The vector is a valid spinner type and is similar to the +`progress-bar' spinner, except without the sorrounding brackets. +CHAR is the character to use for the moving bar (defaults to =)." + (let ((whole-string (concat (make-string (1- width) ?\s) + (make-string 4 (or char ?=)) + (make-string width ?\s)))) + (thread-last (mapcar (lambda (n) (substring whole-string n (+ n width))) + (number-sequence (+ width 3) 0 -1)) + (apply #'vector)))) + (defvar spinner-current nil "Spinner curently being displayed on the `mode-line-process'.") (make-variable-buffer-local 'spinner-current) -- cgit v1.2.3