Emacs - set different intervals for turning the cursor on and off

I want to set different intervals for blinking ON and for blinking OFF. I want to say that I want the cursor to remain visible for 1 second and OFF for 0.2 seconds. I read the cursor documentation, but the closest I found the cursor flashing interval, which changes both ON and OFF flashing.

What is the best way to configure this in Emacs?

+5
source share
2 answers

Emacs does not have this functionality, but you can crack it by adding the following lines to your .emacs file:

(defvar blink-cursor-interval-visible 1)
(defvar blink-cursor-interval-invisible 0.2)

(defadvice internal-show-cursor (before unsymmetric-blink-cursor-interval)
  (when blink-cursor-timer
    (setf (timer--repeat-delay blink-cursor-timer)
          (if (internal-show-cursor-p)
              blink-cursor-interval-visible
            blink-cursor-interval-invisible))))
(ad-activate 'internal-show-cursor)

Emacs , . , , , , , . , .

, , , , , 1 0,2, , . , , , .

, .

+4

blink-cursor-timer-function, , , .

blink-cursor-interval .2

: blink-cursor-timer-function blink-cursor-interval . , .2 , 5 , 1. , 5 0,2 1 , 0,2 .

;; change the interval time to .2
(setq blink-cursor-interval .2)

;; create a variable that counts the timer ticks
(defvar blink-tick-counter 0)

;; this function will be called every .2 seconds
(defun blink-cursor-timer-function ()
  "Timer function of timer `blink-cursor-timer'."
  (if (internal-show-cursor-p)
      (progn
    (if (> blink-tick-counter 4)
        (progn
          (internal-show-cursor nil nil)
          (setq blink-tick-counter 0))
      (setq blink-tick-counter (1+ blink-tick-counter))))
    (internal-show-cursor nil t)))
+2

All Articles