[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master e0ac099: Restart blink cursor timers on interval ch
From: |
Philipp Stephani |
Subject: |
[Emacs-diffs] master e0ac099: Restart blink cursor timers on interval changes |
Date: |
Sun, 2 Oct 2016 17:50:28 +0000 (UTC) |
branch: master
commit e0ac09906b68a6d96466fd12faf45a6e94f9ebbf
Author: Philipp Stephani <address@hidden>
Commit: Philipp Stephani <address@hidden>
Restart blink cursor timers on interval changes
This prevents surprising behavior when timer interval customizations are
only applied whenever the timers happen to be restarted (see Bug#24372).
* lisp/frame.el (blink-cursor--start-idle-timer)
(blink-cursor--start-timer): New functions.
(blink-cursor-start, blink-cursor-check, blink-cursor-mode): Use
the new helper functions.
(blink-cursor-delay, blink-cursor-interval): Restart timers when
the value is changed.
---
lisp/frame.el | 49 ++++++++++++++++++++++++++++++-------------------
1 file changed, 30 insertions(+), 19 deletions(-)
diff --git a/lisp/frame.el b/lisp/frame.el
index d3b6353..ab3b722 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -2029,12 +2029,18 @@ widths."
(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.
@@ -2055,6 +2061,24 @@ The function `blink-cursor-start' is called when the
timer fires.")
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
@@ -2064,9 +2088,7 @@ command starts, by installing a pre-command hook."
;; 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)))
@@ -2113,13 +2135,7 @@ This is done when a frame gets focus. Blink timers may
be stopped by
(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")
@@ -2150,13 +2166,8 @@ terminals, cursor blinking is controlled by the
terminal."
(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)))
+
;; Frame maximization/fullscreen
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master e0ac099: Restart blink cursor timers on interval changes,
Philipp Stephani <=