[elpa] master 709295d 07/10: * spinner: Rename constructor.

2015-08-11 Thread Artur Malabarba
branch: master
commit 709295d6b9f28a94ffcbe73a96767bc675ec7ddd
Author: Artur Malabarba 
Commit: Artur Malabarba 

* spinner: Rename constructor.
---
 README.org |   10 --
 spinner.el |   39 +--
 2 files changed, 25 insertions(+), 24 deletions(-)

diff --git a/README.org b/README.org
index 0d830cc..87fa1cb 100644
--- a/README.org
+++ b/README.org
@@ -28,7 +28,7 @@ You can also define your own as a vector of strings (see the 
examples
 in ~spinner-types~).
 
 ** Minor-modes
-Minor-modes can create a spinner with ~make-spinner~ and then add it
+Minor-modes can create a spinner with ~spinner-create~ and then add it
 to their mode-line lighter. They can then start the spinner by setting
 a variable and calling ~spinner-start-timer~. Finally, they can stop
 the spinner (and the timer) by just setting the same variable to nil.
@@ -37,7 +37,7 @@ Here’s an example for a minor-mode named ~foo~. Assuming that
 ~foo--lighter~ is used as the mode-line lighter, the following code
 will add an *inactive* global spinner to the mode-line.
 #+begin_src emacs-lisp
-(defvar foo--spinner (make-spinner 'rotating-line))
+(defvar foo--spinner (spinner-create 'rotating-line))
 (defconst foo--lighter
   '(" foo" (:eval (spinner-print foo--spinner
 #+end_src
@@ -49,7 +49,7 @@ will add an *inactive* global spinner to the mode-line.
 
 Some minor-modes will need spinners to be buffer-local. To achieve
 that, just make the ~foo--spinner~ variable buffer-local and use the
-third argument of the ~make-spinner~ function. The snippet below is an 
example. 
+third argument of the ~spinner-create~ function. The snippet below is an 
example.
 
 #+begin_src emacs-lisp
 (defvar-local foo--spinner nil)
@@ -58,7 +58,7 @@ third argument of the ~make-spinner~ function. The snippet 
below is an example.
 (defun foo--start-spinner ()
   "Create and start a spinner on this buffer."
   (unless foo--spinner
-(setq foo--spinner (make-spinner 'moon t)))
+(setq foo--spinner (spinner-create 'moon t)))
   (spinner-start foo--spinner))
 #+end_src
 
@@ -67,5 +67,3 @@ third argument of the ~make-spinner~ function. The snippet 
below is an example.
 
 This will use the ~moon~ spinner, but you can use any of the names
 defined in the ~spinner-types~ variable or even define your own.
-
-
diff --git a/spinner.el b/spinner.el
index 05f6707..bcdc16c 100644
--- a/spinner.el
+++ b/spinner.el
@@ -3,7 +3,7 @@
 ;; Copyright (C) 2015 Free Software Foundation, Inc.
 
 ;; Author: Artur Malabarba 
-;; Version: 1.3
+;; Version: 1.3.1
 ;; URL: https://github.com/Malabarba/spinner.el
 ;; Keywords: processes mode-line
 
@@ -54,7 +54,7 @@
 ;; 1.2 Minor-modes
 ;; ───
 ;;
-;;   Minor-modes can create a spinner with `make-spinner' and then add it
+;;   Minor-modes can create a spinner with `spinner-create' and then add it
 ;;   to their mode-line lighter. They can then start the spinner by setting
 ;;   a variable and calling `spinner-start-timer'. Finally, they can stop
 ;;   the spinner (and the timer) by just setting the same variable to nil.
@@ -63,7 +63,7 @@
 ;;   `foo--lighter' is used as the mode-line lighter, the following code
 ;;   will add an *inactive* global spinner to the mode-line.
 ;;   ┌
-;;   │ (defvar foo--spinner (make-spinner 'rotating-line))
+;;   │ (defvar foo--spinner (spinner-create 'rotating-line))
 ;;   │ (defconst foo--lighter
 ;;   │   '(" foo" (:eval (spinner-print foo--spinner
 ;;   └
@@ -75,7 +75,7 @@
 ;;
 ;;   Some minor-modes will need spinners to be buffer-local. To achieve
 ;;   that, just make the `foo--spinner' variable buffer-local and use the
-;;   third argument of the `make-spinner' function. The snippet below is an
+;;   third argument of the `spinner-create' function. The snippet below is an
 ;;   example.
 ;;
 ;;   ┌
@@ -85,7 +85,7 @@
 ;;   │ (defun foo--start-spinner ()
 ;;   │   "Create and start a spinner on this buffer."
 ;;   │   (unless foo--spinner
-;;   │ (setq foo--spinner (make-spinner 'moon t)))
+;;   │ (setq foo--spinner (spinner-create 'moon t)))
 ;;   │   (spinner-start foo--spinner))
 ;;   └
 ;;
@@ -165,12 +165,23 @@ own spinner animations."
((symbolp type) (cdr (assq type spinner-types)))
(t (error "Unknown spinner type: %s" type
 
-;;;###autoload
 (defstruct (spinner
 (:copier nil)
 (:conc-name spinner--)
-(:constructor make-spinner (&optional type buffer-local fps)
-  "Create a spinner of the given TYPE.
+(:constructor make-spinner (&optional type buffer-local fps)))
+  (frames (spinner--type-to-frames type))
+  (counter 0)
+  (fps spinner-frames-per-second)
+  (timer (timer-create) :read-only)
+  (active-p nil)
+  (buffer (when buffer-local
+(if (bufferp buffer-local)
+buffer-local
+  (current-buffer)
+
+;;;###autoload
+(defun spinner-create (&optional type buffer-local fps)
+  "Create a spinner o

[elpa] master 25a84ed 10/10: Merge commit '8d8c459d7757cf5774f11be9147d7a54f5f9bbd7'

2015-08-11 Thread Artur Malabarba
branch: master
commit 25a84edf5607b244fcd7527906cc63aa45e13823
Merge: 7695b59 8d8c459
Author: Artur Malabarba 
Commit: Artur Malabarba 

Merge commit '8d8c459d7757cf5774f11be9147d7a54f5f9bbd7'
---
 packages/spinner/README.org |   61 ++
 packages/spinner/spinner.el |   53 
 2 files changed, 90 insertions(+), 24 deletions(-)

diff --git a/packages/spinner/README.org b/packages/spinner/README.org
index b398ed0..4fb4a4a 100644
--- a/packages/spinner/README.org
+++ b/packages/spinner/README.org
@@ -8,13 +8,11 @@ Add spinners and progress-bars to the mode-line for ongoing 
operations.
 
 * Usage
 
-1. Add ~(spinner "VERSION")~ to your package’s dependencies.
+First of all, don’t forget to add ~(spinner "VERSION")~ to your package’s 
dependencies.
 
-2. Call ~(spinner-start)~ and a spinner will be added to the mode-line.
-
-3. Call ~(spinner-stop)~ on the same buffer when you want to remove it.
-
-* Behavior
+** Major-modes
+1. Just call ~(spinner-start)~ and a spinner will be added to the mode-line.
+2. Call ~(spinner-stop)~ on the same buffer when you want to remove it.
 
 The default spinner is a line drawing that rotates. You can pass an
 argument to ~spinner-start~ to specify which spinner you want. All
@@ -25,3 +23,54 @@ a few examples for you to try:
 - ~(spinner-start 'minibox)~
 - ~(spinner-start 'moon)~
 - ~(spinner-start 'triangle)~
+
+You can also define your own as a vector of strings (see the examples
+in ~spinner-types~).
+
+** Minor-modes
+Minor-modes can create a spinner with ~spinner-create~ and then add it
+to their mode-line lighter. They can then start the spinner by setting
+a variable and calling ~spinner-start-timer~. Finally, they can stop
+the spinner (and the timer) by just setting the same variable to nil.
+
+Here’s an example for a minor-mode named ~foo~. Assuming that
+~foo--lighter~ is used as the mode-line lighter, the following code
+will add an *inactive* global spinner to the mode-line.
+#+begin_src emacs-lisp
+(defvar foo--spinner (spinner-create 'rotating-line))
+(defconst foo--lighter
+  '(" foo" (:eval (spinner-print foo--spinner
+#+end_src
+
+1. To activate the spinner, just call ~(spinner-start foo--spinner)~.
+   It will show up on the mode-line and start animating.
+2. To get rid of it, call ~(spinner-stop foo--spinner)~. It will then
+   disappear again.
+
+Some minor-modes will need spinners to be buffer-local. To achieve
+that, just make the ~foo--spinner~ variable buffer-local and use the
+third argument of the ~spinner-create~ function. The snippet below is an 
example.
+
+#+begin_src emacs-lisp
+(defvar-local foo--spinner nil)
+(defconst foo--lighter
+  '(" foo" (:eval (spinner-print foo--spinner
+(defun foo--start-spinner ()
+  "Create and start a spinner on this buffer."
+  (unless foo--spinner
+(setq foo--spinner (spinner-create 'moon t)))
+  (spinner-start foo--spinner))
+#+end_src
+
+1. To activate the spinner, just call ~(foo--start-spinner)~.
+2. To get rid of it, call ~(spinner-stop foo--spinner)~.
+
+This will use the ~moon~ spinner, but you can use any of the names
+defined in the ~spinner-types~ variable or even define your own.
+
+* Extra options
+
+Both ~spinner-start~ and ~spinner-create~ take extra options to configure the 
spinner, these are:
+
+- ~FPS~: The number of frames to display per second. Defaults to 
~spinner-frames-per-second~.
+- ~DELAY~: After startin a spinner, it still won’t be displayed for this many 
seconds.
diff --git a/packages/spinner/spinner.el b/packages/spinner/spinner.el
index bcdc16c..12fafe6 100644
--- a/packages/spinner/spinner.el
+++ b/packages/spinner/spinner.el
@@ -3,7 +3,7 @@
 ;; Copyright (C) 2015 Free Software Foundation, Inc.
 
 ;; Author: Artur Malabarba 
-;; Version: 1.3.1
+;; Version: 1.4
 ;; URL: https://github.com/Malabarba/spinner.el
 ;; Keywords: processes mode-line
 
@@ -168,19 +168,20 @@ own spinner animations."
 (defstruct (spinner
 (:copier nil)
 (:conc-name spinner--)
-(:constructor make-spinner (&optional type buffer-local fps)))
+(:constructor make-spinner (&optional type buffer-local 
frames-per-second delay-before-start)))
   (frames (spinner--type-to-frames type))
   (counter 0)
-  (fps spinner-frames-per-second)
+  (fps (or frames-per-second spinner-frames-per-second))
   (timer (timer-create) :read-only)
   (active-p nil)
   (buffer (when buffer-local
 (if (bufferp buffer-local)
 buffer-local
-  (current-buffer)
+  (current-buffer
+  (delay (or delay-before-start 0)))
 
 ;;;###autoload
-(defun spinner-create (&optional type buffer-local fps)
+(defun spinner-create (&optional type buffer-local fps delay)
   "Create a spinner of the given TYPE.
 The possible TYPEs are described in `spinner--type-to-frames'.
 
@@ -195,8 +196,13 @@ When started, in order to function properly, the spinner 
runs a
 timer w

[elpa] master fb3fb96 01/10: 1.2

2015-08-11 Thread Artur Malabarba
branch: master
commit fb3fb967f80987a3152929543ccdfdde8f381478
Author: Artur Malabarba 
Commit: Artur Malabarba 

1.2
---
 README.org |2 +-
 spinner.el |8 +++-
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/README.org b/README.org
index 85c649b..b398ed0 100644
--- a/README.org
+++ b/README.org
@@ -8,7 +8,7 @@ Add spinners and progress-bars to the mode-line for ongoing 
operations.
 
 * Usage
 
-1. Add ~(spinner "1.0")~ to your package’s dependencies.
+1. Add ~(spinner "VERSION")~ to your package’s dependencies.
 
 2. Call ~(spinner-start)~ and a spinner will be added to the mode-line.
 
diff --git a/spinner.el b/spinner.el
index 5573030..07d4c2e 100644
--- a/spinner.el
+++ b/spinner.el
@@ -3,7 +3,7 @@
 ;; Copyright (C) 2015 Free Software Foundation, Inc.
 
 ;; Author: Artur Malabarba 
-;; Version: 1.1
+;; Version: 1.2
 ;; Package-Requires: ((cl-lib "0.5"))
 ;; URL: https://github.com/Malabarba/spinner.el
 ;; Keywords: processes mode-line
@@ -25,7 +25,7 @@
 ;; 1 Usage
 ;; ═══
 ;;
-;; 1. Add `(spinner "1.1")' to your package’s dependencies.
+;; 1. Add `(spinner "VERSION")' to your package’s dependencies.
 ;;
 ;; 2. Call `(spinner-start)' and a spinner will be added to the
 ;; mode-line.
@@ -175,9 +175,7 @@ is chosen as the spinner type."
   (when (timerp spinner--timer)
 (cancel-timer spinner--timer))
   (setq spinner--timer nil
-spinner-current nil)
-  (setq mode-line-format
-(remove 'spinner--mode-line-construct mode-line-format)))
+spinner-current nil))
 
 (provide 'spinner)
 



[elpa] master bd2c557 08/10: spinner: Add delay feature

2015-08-11 Thread Artur Malabarba
branch: master
commit bd2c5572c444a9b57fcc4a600695f4fd58eb7f88
Author: Artur Malabarba 
Commit: Artur Malabarba 

spinner: Add delay feature
---
 spinner.el |   53 +++--
 1 files changed, 35 insertions(+), 18 deletions(-)

diff --git a/spinner.el b/spinner.el
index bcdc16c..12fafe6 100644
--- a/spinner.el
+++ b/spinner.el
@@ -3,7 +3,7 @@
 ;; Copyright (C) 2015 Free Software Foundation, Inc.
 
 ;; Author: Artur Malabarba 
-;; Version: 1.3.1
+;; Version: 1.4
 ;; URL: https://github.com/Malabarba/spinner.el
 ;; Keywords: processes mode-line
 
@@ -168,19 +168,20 @@ own spinner animations."
 (defstruct (spinner
 (:copier nil)
 (:conc-name spinner--)
-(:constructor make-spinner (&optional type buffer-local fps)))
+(:constructor make-spinner (&optional type buffer-local 
frames-per-second delay-before-start)))
   (frames (spinner--type-to-frames type))
   (counter 0)
-  (fps spinner-frames-per-second)
+  (fps (or frames-per-second spinner-frames-per-second))
   (timer (timer-create) :read-only)
   (active-p nil)
   (buffer (when buffer-local
 (if (bufferp buffer-local)
 buffer-local
-  (current-buffer)
+  (current-buffer
+  (delay (or delay-before-start 0)))
 
 ;;;###autoload
-(defun spinner-create (&optional type buffer-local fps)
+(defun spinner-create (&optional type buffer-local fps delay)
   "Create a spinner of the given TYPE.
 The possible TYPEs are described in `spinner--type-to-frames'.
 
@@ -195,8 +196,13 @@ When started, in order to function properly, the spinner 
runs a
 timer which periodically calls `force-mode-line-update' in the
 curent buffer.  If BUFFER-LOCAL was set at creation time, then
 `force-mode-line-update' is called in that buffer instead.  When
-the spinner is stopped, the timer is deactivated."
-  (make-spinner type buffer-local fps))
+the spinner is stopped, the timer is deactivated.
+
+DELAY, if given, is the number of seconds to wait after starting
+the spinner before actually displaying it. It is safe to cancel
+the spinner before this time, in which case it won't display at
+all."
+  (make-spinner type buffer-local fps delay))
 
 (defun spinner-print (spinner)
   "Return a string of the current frame of SPINNER.
@@ -204,8 +210,9 @@ If SPINNER is nil, just return nil.
 Designed to be used in the mode-line with:
 (:eval (spinner-print some-spinner))"
   (when (and spinner (spinner--active-p spinner))
-(elt (spinner--frames spinner)
- (spinner--counter spinner
+(let ((frame (spinner--counter spinner)))
+  (when (>= frame 0)
+(elt (spinner--frames spinner) frame)
 
 (defun spinner--timer-function (spinner)
   "Function called to update SPINNER.
@@ -216,7 +223,9 @@ stop the SPINNER's timer."
 (and buffer (not (buffer-live-p buffer
 (spinner-stop spinner)
   ;; Increment
-  (callf (lambda (x) (% (1+ x) (length (spinner--frames spinner
+  (callf (lambda (x) (if (< x 0)
+(1+ x)
+  (% (1+ x) (length (spinner--frames spinner)
   (spinner--counter spinner))
   ;; Update mode-line.
   (if (buffer-live-p buffer)
@@ -225,15 +234,19 @@ stop the SPINNER's timer."
 (force-mode-line-update)
 
 (defun spinner--start-timer (spinner)
-  "Start a SPINNER's timer at FPS frames per second."
+  "Start a SPINNER's timer."
   (let ((old-timer (spinner--timer spinner)))
 (when (timerp old-timer)
   (cancel-timer old-timer))
 
 (setf (spinner--active-p spinner) t)
+
+(unless (ignore-errors (> (spinner--fps spinner) 0))
+  (error "A spinner's FPS must be a positive number"))
+(setf (spinner--counter spinner) (- (* (or (spinner--delay spinner) 0)
+(spinner--fps spinner
 ;; Create timer.
-(let* ((repeat (/ 1.0 (or (spinner--fps spinner)
-  spinner-frames-per-second)))
+(let* ((repeat (/ 1.0 (spinner--fps spinner)))
(time (timer-next-integral-multiple-of-time (current-time) repeat))
;; Create the timer as a lex variable so it can cancel itself.
(timer (spinner--timer spinner)))
@@ -246,7 +259,7 @@ stop the SPINNER's timer."
 
 ;;; The main functions
 ;;;###autoload
-(defun spinner-start (&optional type-or-object fps)
+(defun spinner-start (&optional type-or-object fps delay)
   "Start a mode-line spinner of given TYPE-OR-OBJECT.
 If TYPE-OR-OBJECT is an object created with `make-spinner',
 simply activate it.  This method is designed for minor modes, so
@@ -265,13 +278,16 @@ anywhere to stop this spinner.  You can also call 
`spinner-stop'
 in the same buffer where the spinner was created.
 
 FPS, if given, is the number of desired frames per second.
-Default is `spinner-frames-per-second'."
+Default is `spinner-frames-per-second'.
+
+DELAY, if given, is the numbe

[elpa] master updated (7695b59 -> 25a84ed)

2015-08-11 Thread Artur Malabarba
malabarba pushed a change to branch master.

  from  7695b59   * el-search.el: Add missing footer
   new  fb3fb96   1.2
   new  7d222f4   spinner: Generalize to arbitrary variables
   new  b6dc924   spinner: Document new functionality
   new  46c545b   spinner: Iron out some kinks in the minor-mode behavior
   new  60205a4   Rewrite spinners completely.
   new  59ef469   Implement spinner-start-print
   new  709295d   * spinner: Rename constructor.
   new  bd2c557   spinner: Add delay feature
   new  8d8c459   spinner: More doc
   new  25a84ed   Merge commit '8d8c459d7757cf5774f11be9147d7a54f5f9bbd7'


Summary of changes:
 packages/spinner/README.org |   61 ++
 packages/spinner/spinner.el |   53 
 2 files changed, 90 insertions(+), 24 deletions(-)



[elpa] master 60205a4 05/10: Rewrite spinners completely.

2015-08-11 Thread Artur Malabarba
branch: master
commit 60205a4dafcf81271304166e2c48fd6107db95ee
Author: Artur Malabarba 
Commit: Artur Malabarba 

Rewrite spinners completely.
---
 README.org |   56 +++-
 spinner.el |  303 +++
 2 files changed, 214 insertions(+), 145 deletions(-)

diff --git a/README.org b/README.org
index 9eab94f..0d830cc 100644
--- a/README.org
+++ b/README.org
@@ -28,32 +28,44 @@ You can also define your own as a vector of strings (see 
the examples
 in ~spinner-types~).
 
 ** Minor-modes
-Minor-modes can create a spinner (that can be added to the mode’s
-lighter) with ~spinner-make-construct~. They can then start the
-spinner by setting a variable and calling ~spinner-start-timer~.
-Finally, they can stop the spinner (and the timer) by just setting the
-same variable to nil.
+Minor-modes can create a spinner with ~make-spinner~ and then add it
+to their mode-line lighter. They can then start the spinner by setting
+a variable and calling ~spinner-start-timer~. Finally, they can stop
+the spinner (and the timer) by just setting the same variable to nil.
+
+Here’s an example for a minor-mode named ~foo~. Assuming that
+~foo--lighter~ is used as the mode-line lighter, the following code
+will add an *inactive* global spinner to the mode-line.
+#+begin_src emacs-lisp
+(defvar foo--spinner (make-spinner 'rotating-line))
+(defconst foo--lighter
+  '(" foo" (:eval (spinner-print foo--spinner
+#+end_src
+
+1. To activate the spinner, just call ~(spinner-start foo--spinner)~.
+   It will show up on the mode-line and start animating.
+2. To get rid of it, call ~(spinner-stop foo--spinner)~. It will then
+   disappear again.
+
+Some minor-modes will need spinners to be buffer-local. To achieve
+that, just make the ~foo--spinner~ variable buffer-local and use the
+third argument of the ~make-spinner~ function. The snippet below is an 
example. 
 
-Here’s an example for a minor-mode named ~foo~.
 #+begin_src emacs-lisp
-(defvar foo--spinner nil)
-(defvar foo--timer nil)
+(defvar-local foo--spinner nil)
 (defconst foo--lighter
-  (list " foo"
-(spinner-make-construct 'foo--spinner 'foo--timer)))
-
-(defun foo--start-spinning ()
-  "Start foo's spinner."
-  (setq foo--spinner
-(cdr (assq 'horizontal-bar spinner-types)))
-  (spinner-start-timer 'foo--spinner 'foo--timer))
-
-(defun foo--stop-spinning ()
-  "Stop foo's spinner"
-  (setq foo--spinner nil))
+  '(" foo" (:eval (spinner-print foo--spinner
+(defun foo--start-spinner ()
+  "Create and start a spinner on this buffer."
+  (unless foo--spinner
+(setq foo--spinner (make-spinner 'moon t)))
+  (spinner-start foo--spinner))
 #+end_src
 
-This will use the ~horizontal-bar~ spinner, but you can use anything
-defined in the ~spinner-types~ variable, or even define your own.
+1. To activate the spinner, just call ~(foo--start-spinner)~.
+2. To get rid of it, call ~(spinner-stop foo--spinner)~.
+
+This will use the ~moon~ spinner, but you can use any of the names
+defined in the ~spinner-types~ variable or even define your own.
 
 
diff --git a/spinner.el b/spinner.el
index f81fa29..34427b2 100644
--- a/spinner.el
+++ b/spinner.el
@@ -3,8 +3,7 @@
 ;; Copyright (C) 2015 Free Software Foundation, Inc.
 
 ;; Author: Artur Malabarba 
-;; Version: 1.2.1
-;; Package-Requires: ((cl-lib "0.5"))
+;; Version: 1.3
 ;; URL: https://github.com/Malabarba/spinner.el
 ;; Keywords: processes mode-line
 
@@ -22,6 +21,7 @@
 ;; along with this program.  If not, see .
 
 ;;; Commentary:
+;;
 ;; 1 Usage
 ;; ═══
 ;;
@@ -54,36 +54,51 @@
 ;; 1.2 Minor-modes
 ;; ───
 ;;
-;;   Minor-modes can create a spinner (that can be added to the mode’s
-;;   lighter) with `spinner-make-construct'. They can then start the
-;;   spinner by setting a variable and calling `spinner-start-timer'.
-;;   Finally, they can stop the spinner (and the timer) by just setting the
-;;   same variable to nil.
+;;   Minor-modes can create a spinner with `make-spinner' and then add it
+;;   to their mode-line lighter. They can then start the spinner by setting
+;;   a variable and calling `spinner-start-timer'. Finally, they can stop
+;;   the spinner (and the timer) by just setting the same variable to nil.
+;;
+;;   Here’s an example for a minor-mode named `foo'. Assuming that
+;;   `foo--lighter' is used as the mode-line lighter, the following code
+;;   will add an *inactive* global spinner to the mode-line.
+;;   ┌
+;;   │ (defvar foo--spinner (make-spinner 'rotating-line))
+;;   │ (defconst foo--lighter
+;;   │   '(" foo" (:eval (spinner-print foo--spinner
+;;   └
+;;
+;;   1. To activate the spinner, just call `(spinner-start foo--spinner)'.
+;;  It will show up on the mode-line and start animating.
+;;   2. To get rid of it, call `(spinner-stop foo--spinner)'. It will then
+;;  disappear again.
+;;
+;;   Some minor-modes will need spinners to be buffer-local. To achieve
+;;

[elpa] master 8d8c459 09/10: spinner: More doc

2015-08-11 Thread Artur Malabarba
branch: master
commit 8d8c459d7757cf5774f11be9147d7a54f5f9bbd7
Author: Artur Malabarba 
Commit: Artur Malabarba 

spinner: More doc
---
 README.org |7 +++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/README.org b/README.org
index 87fa1cb..4fb4a4a 100644
--- a/README.org
+++ b/README.org
@@ -67,3 +67,10 @@ third argument of the ~spinner-create~ function. The snippet 
below is an example
 
 This will use the ~moon~ spinner, but you can use any of the names
 defined in the ~spinner-types~ variable or even define your own.
+
+* Extra options
+
+Both ~spinner-start~ and ~spinner-create~ take extra options to configure the 
spinner, these are:
+
+- ~FPS~: The number of frames to display per second. Defaults to 
~spinner-frames-per-second~.
+- ~DELAY~: After startin a spinner, it still won’t be displayed for this many 
seconds.



[elpa] master 46c545b 04/10: spinner: Iron out some kinks in the minor-mode behavior

2015-08-11 Thread Artur Malabarba
branch: master
commit 46c545bf532f3798a0e73ff42705ddaafa9deac6
Author: Artur Malabarba 
Commit: Artur Malabarba 

spinner: Iron out some kinks in the minor-mode behavior
---
 spinner.el |   26 +++---
 1 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/spinner.el b/spinner.el
index 47dad2b..f81fa29 100644
--- a/spinner.el
+++ b/spinner.el
@@ -3,7 +3,7 @@
 ;; Copyright (C) 2015 Free Software Foundation, Inc.
 
 ;; Author: Artur Malabarba 
-;; Version: 1.2
+;; Version: 1.2.1
 ;; Package-Requires: ((cl-lib "0.5"))
 ;; URL: https://github.com/Malabarba/spinner.el
 ;; Keywords: processes mode-line
@@ -120,16 +120,20 @@ vector, the spinner itself.")
   "Make a mode-line spinner construct, using symbol SPINNER-VAR.
 SPINNER-VAR is the name of the variable holding the spinner type
 to be used (one of the cdr's in `spinner-types').  To st"
-  `((,spinner-var
- (" "
-  (:eval (elt ,spinner-var
-  (% spinner--counter
- (length ,spinner-var)
- (,timer-var
-  (:eval (spinner-stop ,spinner-var ,timer-var))
+  `(,spinner-var
+(:eval (elt ,spinner-var
+(% spinner--counter
+   (length ,spinner-var
+(,timer-var
+ (:eval (spinner-stop ',spinner-var ',timer-var)
 
 (defconst spinner--mode-line-construct
-  (spinner-make-construct 'spinner-current 'spinner--timer)
+  '(spinner-current
+(" " (:eval (elt spinner-current
+ (% spinner--counter
+(length spinner-current)
+(spinner--timer
+ (:eval (spinner-stop 'spinner-current 'spinner--timer
   "Construct used to display the spinner.")
 (put 'spinner--mode-line-construct 'risky-local-variable t)
 
@@ -143,7 +147,7 @@ Applications can override this value.")
 
 
 ;;; The main functions
-(defun spinner-start-timer (fps spinner-var timer-var)
+(defun spinner-start-timer (spinner-var timer-var &optional fps)
   "Start a spinner timer at FPS frames per second.
 SPINNER-VAR is the name of the variable holding the spinner type,
 and TIMER-VAR is the name of the variable that will be used to
@@ -217,7 +221,7 @@ is chosen as the spinner type."
 'spinner--mode-line-construct)))
 
   ;; Create timer.
-  (spinner-start-timer fps 'spinner-current 'spinner--timer))
+  (spinner-start-timer 'spinner-current 'spinner--timer fps))
 
 (defun spinner-stop (&optional spinner-var timer-var)
   "Stop the current buffer's spinner."



[elpa] master 7d222f4 02/10: spinner: Generalize to arbitrary variables

2015-08-11 Thread Artur Malabarba
branch: master
commit 7d222f4cd526652b10894a1cdf5aa85a920ec8ce
Author: Artur Malabarba 
Commit: Artur Malabarba 

spinner: Generalize to arbitrary variables
---
 spinner.el |   80 
 1 files changed, 48 insertions(+), 32 deletions(-)

diff --git a/spinner.el b/spinner.el
index 07d4c2e..a40005c 100644
--- a/spinner.el
+++ b/spinner.el
@@ -82,14 +82,20 @@ vector, the spinner itself.")
   "Current frame of the spinner.")
 (make-variable-buffer-local 'spinner--counter)
 
-(defconst spinner--mode-line-construct
-  '((spinner-current
+(defun spinner-make-construct (spinner-var timer-var)
+  "Make a mode-line spinner construct, using symbol SPINNER-VAR.
+SPINNER-VAR is the name of the variable holding the spinner type
+to be used (one of the cdr's in `spinner-types').  To st"
+  `((,spinner-var
  (" "
-  (:eval (elt spinner-current
+  (:eval (elt ,spinner-var
   (% spinner--counter
- (length spinner-current)
- (spinner--timer
-  (:eval (spinner-stop)
+ (length ,spinner-var)
+ (,timer-var
+  (:eval (spinner-stop ,spinner-var ,timer-var))
+
+(defconst spinner--mode-line-construct
+  (spinner-make-construct 'spinner-current 'spinner--timer)
   "Construct used to display the spinner.")
 (put 'spinner--mode-line-construct 'risky-local-variable t)
 
@@ -102,7 +108,34 @@ vector, the spinner itself.")
 Applications can override this value.")
 
 
-;;; The main function
+;;; The main functions
+(defun spinner-start-timer (fps spinner-var timer-var)
+  "Start a spinner timer at FPS frames per second.
+SPINNER-VAR is the name of the variable holding the spinner type,
+and TIMER-VAR is the name of the variable that will be used to
+hold the timer."
+  (let ((old-timer (symbol-value timer-var)))
+(when (timerp old-timer)
+  (cancel-timer old-timer))
+;; Create timer.
+(let ((buffer (current-buffer))
+  ;; Create the timer as a lex variable so it can cancel itself.
+  (timer (run-at-time t
+  (/ 1.0 (or fps spinner-frames-per-second))
+  #'ignore)))
+  (timer-set-function
+   timer (lambda ()
+   (if (buffer-live-p buffer)
+   (with-current-buffer buffer
+ (setq spinner--counter (1+ spinner--counter))
+ (force-mode-line-update))
+ (ignore-errors (cancel-timer timer)
+  (set timer-var timer)
+  ;; Return a stopping function.
+  (lambda () (when (buffer-live-p buffer)
+  (with-current-buffer buffer
+(spinner-stop spinner-var timer-var)))
+
 ;;;###autoload
 (defun spinner-start (&optional type fps noadd)
   "Start a mode-line spinner of given TYPE.
@@ -150,32 +183,15 @@ is chosen as the spinner type."
 'spinner--mode-line-construct)))
 
   ;; Create timer.
-  (when (timerp spinner--timer)
-(cancel-timer spinner--timer))
-  (let ((buffer (current-buffer))
-;; Create the timer as a lex variable so it can cancel itself.
-(timer (run-at-time t
-(/ 1.0 (or fps spinner-frames-per-second))
-#'ignore)))
-(timer-set-function
- timer (lambda ()
- (if (buffer-live-p buffer)
- (with-current-buffer buffer
-   (setq spinner--counter (1+ spinner--counter))
-   (force-mode-line-update))
-   (ignore-errors (cancel-timer timer)
-(setq spinner--timer timer)
-;; Return a stopping function.
-(lambda () (when (buffer-live-p buffer)
-(with-current-buffer buffer
-  (spinner-stop))
-
-(defun spinner-stop ()
+  (spinner-start-timer fps 'spinner-current 'spinner--timer))
+
+(defun spinner-stop (&optional spinner-var timer-var)
   "Stop the current buffer's spinner."
-  (when (timerp spinner--timer)
-(cancel-timer spinner--timer))
-  (setq spinner--timer nil
-spinner-current nil))
+  (let ((timer (symbol-value timer-var)))
+(when (timerp timer)
+  (cancel-timer timer))
+(set (or timer-var 'spinner--timer) nil)
+(set (or spinner-var 'spinner-current) nil)))
 
 (provide 'spinner)
 



[elpa] master 59ef469 06/10: Implement spinner-start-print

2015-08-11 Thread Artur Malabarba
branch: master
commit 59ef4695030bb43a43611183239605f7e2eb48f4
Author: Artur Malabarba 
Commit: Artur Malabarba 

Implement spinner-start-print
---
 spinner.el |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/spinner.el b/spinner.el
index 34427b2..05f6707 100644
--- a/spinner.el
+++ b/spinner.el
@@ -280,6 +280,12 @@ Default is `spinner-frames-per-second'."
   (when fps (setf (spinner--fps type-or-object) fps))
   (spinner--start-timer type-or-object))
 
+(defun spinner-start-print (spinner)
+  "Like `spinner-print', but also start SPINNER if it's not active."
+  (unless (spinner--active-p spinner)
+(spinner-start spinner))
+  (spinner-print spinner))
+
 (defun spinner-stop (&optional spinner)
   "Stop the current buffer's spinner."
   (let* ((spinner (or spinner spinner-current))



[elpa] master b6dc924 03/10: spinner: Document new functionality

2015-08-11 Thread Artur Malabarba
branch: master
commit b6dc9242e1ab5a1edee1531b1b282b9c18f5ad39
Author: Artur Malabarba 
Commit: Artur Malabarba 

spinner: Document new functionality
---
 README.org |   44 ++-
 spinner.el |   66 +--
 2 files changed, 88 insertions(+), 22 deletions(-)

diff --git a/README.org b/README.org
index b398ed0..9eab94f 100644
--- a/README.org
+++ b/README.org
@@ -8,13 +8,11 @@ Add spinners and progress-bars to the mode-line for ongoing 
operations.
 
 * Usage
 
-1. Add ~(spinner "VERSION")~ to your package’s dependencies.
+First of all, don’t forget to add ~(spinner "VERSION")~ to your package’s 
dependencies.
 
-2. Call ~(spinner-start)~ and a spinner will be added to the mode-line.
-
-3. Call ~(spinner-stop)~ on the same buffer when you want to remove it.
-
-* Behavior
+** Major-modes
+1. Just call ~(spinner-start)~ and a spinner will be added to the mode-line.
+2. Call ~(spinner-stop)~ on the same buffer when you want to remove it.
 
 The default spinner is a line drawing that rotates. You can pass an
 argument to ~spinner-start~ to specify which spinner you want. All
@@ -25,3 +23,37 @@ a few examples for you to try:
 - ~(spinner-start 'minibox)~
 - ~(spinner-start 'moon)~
 - ~(spinner-start 'triangle)~
+
+You can also define your own as a vector of strings (see the examples
+in ~spinner-types~).
+
+** Minor-modes
+Minor-modes can create a spinner (that can be added to the mode’s
+lighter) with ~spinner-make-construct~. They can then start the
+spinner by setting a variable and calling ~spinner-start-timer~.
+Finally, they can stop the spinner (and the timer) by just setting the
+same variable to nil.
+
+Here’s an example for a minor-mode named ~foo~.
+#+begin_src emacs-lisp
+(defvar foo--spinner nil)
+(defvar foo--timer nil)
+(defconst foo--lighter
+  (list " foo"
+(spinner-make-construct 'foo--spinner 'foo--timer)))
+
+(defun foo--start-spinning ()
+  "Start foo's spinner."
+  (setq foo--spinner
+(cdr (assq 'horizontal-bar spinner-types)))
+  (spinner-start-timer 'foo--spinner 'foo--timer))
+
+(defun foo--stop-spinning ()
+  "Stop foo's spinner"
+  (setq foo--spinner nil))
+#+end_src
+
+This will use the ~horizontal-bar~ spinner, but you can use anything
+defined in the ~spinner-types~ variable, or even define your own.
+
+
diff --git a/spinner.el b/spinner.el
index a40005c..47dad2b 100644
--- a/spinner.el
+++ b/spinner.el
@@ -25,28 +25,62 @@
 ;; 1 Usage
 ;; ═══
 ;;
-;; 1. Add `(spinner "VERSION")' to your package’s dependencies.
+;;   First of all, don’t forget to add `(spinner "VERSION")' to your
+;;   package’s dependencies.
 ;;
-;; 2. Call `(spinner-start)' and a spinner will be added to the
-;; mode-line.
 ;;
-;; 3. Call `(spinner-stop)' on the same buffer when you want to remove
-;; it.
+;; 1.1 Major-modes
+;; ───
 ;;
+;;   1. Just call `(spinner-start)' and a spinner will be added to the
+;;  mode-line.
+;;   2. Call `(spinner-stop)' on the same buffer when you want to remove
+;;  it.
 ;;
-;; 2 Behavior
-;; ══
+;;   The default spinner is a line drawing that rotates. You can pass an
+;;   argument to `spinner-start' to specify which spinner you want. All
+;;   possibilities are listed in the `spinner-types' variable, but here are
+;;   a few examples for you to try:
 ;;
-;; The default spinner is a line drawing that rotates. You can pass an
-;; argument to `spinner-start' to specify which spinner you want. All
-;; possibilities are listed in the `spinner-types' variable, but here are
-;; a few examples for you to try:
+;;   • `(spinner-start 'vertical-breathing 10)'
+;;   • `(spinner-start 'minibox)'
+;;   • `(spinner-start 'moon)'
+;;   • `(spinner-start 'triangle)'
 ;;
-;; • `(spinner-start 'vertical-breathing 10)'
-;; • `(spinner-start 'minibox)'
-;; • `(spinner-start 'moon)'
-;; • `(spinner-start 'triangle)'
-
+;;   You can also define your own as a vector of strings (see the examples
+;;   in `spinner-types').
+;;
+;;
+;; 1.2 Minor-modes
+;; ───
+;;
+;;   Minor-modes can create a spinner (that can be added to the mode’s
+;;   lighter) with `spinner-make-construct'. They can then start the
+;;   spinner by setting a variable and calling `spinner-start-timer'.
+;;   Finally, they can stop the spinner (and the timer) by just setting the
+;;   same variable to nil.
+;;
+;;   Here’s an example for a minor-mode named `foo'.
+;;   ┌
+;;   │ (defvar foo--spinner nil)
+;;   │ (defvar foo--timer nil)
+;;   │ (defconst foo--lighter
+;;   │   (list " foo"
+;;   │ (spinner-make-construct 'foo--spinner 'foo--timer)))
+;;   │
+;;   │ (defun foo--start-spinning ()
+;;   │   "Start foo's spinner."
+;;   │   (setq foo--spinner
+;;   │ (cdr (assq 'horizontal-bar spinner-types)))
+;;   │   (spinner-start-timer 'foo--spinner 'foo--timer))
+;;   │
+;;   │ (defun foo--stop-spinning ()
+;;   │   "Stop foo's spinner"
+;;   │   (setq foo--spinner nil