diff options
author | Artur Malabarba <bruce.connor.am@gmail.com> | 2016-02-08 09:50:13 +0000 |
---|---|---|
committer | Artur Malabarba <bruce.connor.am@gmail.com> | 2016-02-08 09:51:17 +0000 |
commit | 4e04a983b86ee698ff417eae4646756daef434ba (patch) | |
tree | 22ae544310836de85744823f6a498e06fdee9c6c | |
parent | c651ba8711b23725052bfc6b572cbf4e83449893 (diff) |
Make spinner-stop never signal
-rw-r--r-- | spinner.el | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -3,7 +3,7 @@ ;; Copyright (C) 2015 Free Software Foundation, Inc. ;; Author: Artur Malabarba <emacs@endlessparentheses.com> -;; Version: 1.6 +;; Version: 1.7 ;; URL: https://github.com/Malabarba/spinner.el ;; Keywords: processes mode-line @@ -319,13 +319,16 @@ this time, in which case it won't display at all." (spinner-print spinner)) (defun spinner-stop (&optional spinner) - "Stop the current buffer's spinner." - (let* ((spinner (or spinner spinner-current)) - (timer (spinner--timer spinner))) - (when (timerp timer) - (cancel-timer timer)) - (setf (spinner--active-p spinner) nil) - (force-mode-line-update))) + "Stop SPINNER, defaulting to the current buffer's spinner. +It is always safe to call this function, even if there is no +active spinner." + (let ((spinner (or spinner spinner-current))) + (when (spinner-p spinner) + (let ((timer (spinner--timer spinner))) + (when (timerp timer) + (cancel-timer timer))) + (setf (spinner--active-p spinner) nil) + (force-mode-line-update)))) (provide 'spinner) |