(defcustom blink-cursor-delay 0.5
"Seconds of idle time after which cursor starts to blink."
:type 'number
- :group 'cursor)
+ :group 'cursor
+ :set (lambda (symbol value)
+ (set-default symbol value)
+ (when blink-cursor-idle-timer (blink-cursor--start-idle-timer))))
(defcustom blink-cursor-interval 0.5
"Length of cursor blink interval in seconds."
:type 'number
- :group 'cursor)
+ :group 'cursor
+ :set (lambda (symbol value)
+ (set-default symbol value)
+ (when blink-cursor-timer (blink-cursor--start-timer))))
(defcustom blink-cursor-blinks 10
"How many times to blink before using a solid cursor on NS, X, and MS-Windows.
This timer calls `blink-cursor-timer-function' every
`blink-cursor-interval' seconds.")
+(defun blink-cursor--start-idle-timer ()
+ "Start the `blink-cursor-idle-timer'."
+ (when blink-cursor-idle-timer (cancel-timer blink-cursor-idle-timer))
+ (setq blink-cursor-idle-timer
+ ;; The 0.2 sec limitation from below is to avoid erratic
+ ;; behavior (or downright failure to display the cursor
+ ;; during command execution) if they set blink-cursor-delay
+ ;; to a very small or even zero value.
+ (run-with-idle-timer (max 0.2 blink-cursor-delay)
+ :repeat #'blink-cursor-start)))
+
+(defun blink-cursor--start-timer ()
+ "Start the `blink-cursor-timer'."
+ (when blink-cursor-timer (cancel-timer blink-cursor-timer))
+ (setq blink-cursor-timer
+ (run-with-timer blink-cursor-interval blink-cursor-interval
+ #'blink-cursor-timer-function)))
+
(defun blink-cursor-start ()
"Timer function called from the timer `blink-cursor-idle-timer'.
This starts the timer `blink-cursor-timer', which makes the cursor blink
;; Set up the timer first, so that if this signals an error,
;; blink-cursor-end is not added to pre-command-hook.
(setq blink-cursor-blinks-done 1)
- (setq blink-cursor-timer
- (run-with-timer blink-cursor-interval blink-cursor-interval
- 'blink-cursor-timer-function))
+ (blink-cursor--start-timer)
(add-hook 'pre-command-hook 'blink-cursor-end)
(internal-show-cursor nil nil)))
(when (and blink-cursor-mode
(not blink-cursor-idle-timer))
(remove-hook 'post-command-hook 'blink-cursor-check)
- (setq blink-cursor-idle-timer
- ;; The 0.2 sec limitation from below is to avoid erratic
- ;; behavior (or downright failure to display the cursor
- ;; during command execution) if they set blink-cursor-delay
- ;; to a very small or even zero value.
- (run-with-idle-timer (max 0.2 blink-cursor-delay)
- :repeat #'blink-cursor-start))))
+ (blink-cursor--start-idle-timer)))
(define-obsolete-variable-alias 'blink-cursor 'blink-cursor-mode "22.1")
(when blink-cursor-mode
(add-hook 'focus-in-hook #'blink-cursor-check)
(add-hook 'focus-out-hook #'blink-cursor-suspend)
- (setq blink-cursor-idle-timer
- ;; The 0.2 sec limitation from below is to avoid erratic
- ;; behavior (or downright failure to display the cursor
- ;; during command execution) if they set blink-cursor-delay
- ;; to a very small or even zero value.
- (run-with-idle-timer (max 0.2 blink-cursor-delay)
- :repeat #'blink-cursor-start))))
+ (blink-cursor--start-idle-timer)))
+
\f
;; Frame maximization/fullscreen