File: spinner.el.html
1 Usage
═══════
First of all, don’t forget to add (spinner "VERSION") to your
package’s dependencies.
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.
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)'
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 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.
┌────
│ (defvar foo--spinner (spinner-create '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
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.
┌────
│ (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))
└────
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.
Defined variables (4)
spinner--mode-line-construct | Construct used to display a spinner in ‘mode-line-process’. |
spinner-current | Spinner currently being displayed on the ‘mode-line-process’. |
spinner-frames-per-second | Default speed at which spinners spin, in frames per second. |
spinner-types | Predefined alist of spinners. |
Defined functions (27)
make-spinner | (&optional TYPE BUFFER-LOCAL FRAMES-PER-SECOND DELAY-BEFORE-START) |
make-spinner--cmacro | (CL-WHOLE-ARG &optional TYPE BUFFER-LOCAL FRAMES-PER-SECOND DELAY-BEFORE-START) |
spinner--active-p | (CL-X) |
spinner--active-p--cmacro | (CL-WHOLE-ARG CL-X) |
spinner--buffer | (CL-X) |
spinner--buffer--cmacro | (CL-WHOLE-ARG CL-X) |
spinner--counter | (CL-X) |
spinner--counter--cmacro | (CL-WHOLE-ARG CL-X) |
spinner--delay | (CL-X) |
spinner--delay--cmacro | (CL-WHOLE-ARG CL-X) |
spinner--fps | (CL-X) |
spinner--fps--cmacro | (CL-WHOLE-ARG CL-X) |
spinner--frames | (CL-X) |
spinner--frames--cmacro | (CL-WHOLE-ARG CL-X) |
spinner--start-timer | (SPINNER) |
spinner--timer | (CL-X) |
spinner--timer--cmacro | (CL-WHOLE-ARG CL-X) |
spinner--timer-function | (SPINNER) |
spinner--type-to-frames | (TYPE) |
spinner-create | (&optional TYPE BUFFER-LOCAL FPS DELAY) |
spinner-make-progress-bar | (WIDTH &optional CHAR) |
spinner-p | (CL-X) |
spinner-p--cmacro | (CL-WHOLE-ARG CL-X) |
spinner-print | (SPINNER) |
spinner-start | (&optional TYPE-OR-OBJECT FPS DELAY) |
spinner-start-print | (SPINNER) |
spinner-stop | (&optional SPINNER) |