aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGene Pasquet <gene@pacerevenue.com>2026-08-25 17:31:48 +0100
committerGene Pasquet <gene@pacerevenue.com>2026-08-25 17:31:48 +0100
commite0807c722b5923bf0bed7bba41ccc216b30c1056 (patch)
treeeda18b1e0085d90e00b9b5a2b8546ba35d92e297
parent81a09e8da14c35ea9e90d872761217f07e18238c (diff)
Improvements
-rw-r--r--cursor-breathe-mode.el20
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