diff options
| -rw-r--r-- | cursor-breathe-mode.el | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/cursor-breathe-mode.el b/cursor-breathe-mode.el index 06f2341..05fe98f 100644 --- a/cursor-breathe-mode.el +++ b/cursor-breathe-mode.el @@ -41,9 +41,12 @@ (defvar curbreathe/increment +1 "Direction of the animation") +(defvar curbreathe/current-size nil + "Current cursor width") (defvar curbreathe/timer nil "Global variable holding the animation timer") +;;;###autoload (define-minor-mode cursor-breathe-mode "Animate the cursor to make it more visible" :global t @@ -51,16 +54,27 @@ (if cursor-breathe-mode (progn (setq curbreathe/original-cursor-type cursor-type) + (setq curbreathe/current-size curbreathe/min-size) (setq curbreathe/timer (run-with-timer 0 (/ 1.0 curbreathe/frame-rate) #'curbreathe/step))) (progn (cancel-timer curbreathe/timer) - (setq-default cursor-type curbreathe/original-cursor-type)))) + (setq-default cursor-type curbreathe/original-cursor-type) + (curbreathe/update-all-cursors curbreathe/original-cursor-type)))) + +(defun curbreathe/update-all-cursors (shape) + (dolist (buf (buffer-list)) + (when (local-variable-p 'cursor-type buf) + (with-current-buffer buf + (setq cursor-type shape))))) (defun curbreathe/step () - (let ((new-value (+ curbreathe/increment (cdr cursor-type)))) + (let ((new-value (+ curbreathe/increment curbreathe/current-size))) (cond ((>= new-value curbreathe/max-size) (setq curbreathe/increment -1)) ((<= new-value curbreathe/min-size) (setq curbreathe/increment +1))) - (setq-default cursor-type (cons curbreathe/cursor-type new-value)))) + (setq curbreathe/current-size new-value) + (let ((shape (cons curbreathe/cursor-type new-value))) + (setq-default cursor-type shape) + (curbreathe/update-all-cursors shape)))) (provide 'cursor-breathe-mode) ;;; cursor-breathe-mode.el ends here |
