我想爲閃爍開啓和閃爍關閉設置不同的時間間隔。我的意思是,我希望光標保持可見1秒,關閉0.2秒。 我讀了光標文檔,但最近發現是閃爍光標間隔,它可以改變ON和OFF閃爍。Emacs - 爲光標閃爍打開和關閉設置不同的時間間隔
在Emacs中定製它的最好方法是什麼?
我想爲閃爍開啓和閃爍關閉設置不同的時間間隔。我的意思是,我希望光標保持可見1秒,關閉0.2秒。 我讀了光標文檔,但最近發現是閃爍光標間隔,它可以改變ON和OFF閃爍。Emacs - 爲光標閃爍打開和關閉設置不同的時間間隔
在Emacs中定製它的最好方法是什麼?
有內置到Emacs沒有這樣的功能,但是你可以通過添加如下行到你的.emacs本事文件:
(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實現光標的一個名爲切換功能閃爍由一個計時器。每次調用函數時,它都會在光標當前可見時隱藏光標,或者在光標不可見時將其顯示。不幸的是,定時器以固定的時間間隔調用這個函數。
爲了根據光標的狀態實現不同的延遲時間,以上代碼advises顯示或隱藏光標的內部函數。每次調用此函數時,建議都會將計時器的延遲時間更改爲1或0.2,具體取決於光標是否可見。也就是說,每當光標被隱藏或顯示時,定時器的延遲時間就會改變。
很駭人,但它的確有竅門。
我能夠修改blink-cursor-timer-function
函數來支持你想要我相信的東西。
首先,你需要的blink-cursor-interval
值修改到0.2
那麼這段代碼應該做的伎倆: blink-cursor-timer-function
每blink-cursor-interval
秒調用。 所以這個功能每2秒會被調用一次,它會保持5次通話的光標,然後關閉1次。所以每次通話0.2秒5次通話會給你1秒的通電時間,秒的關閉時間。
;; 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)))
你的解決方案工作正常,但其他答案看起來更清潔,我只能選擇一個。無論如何,也請感謝你 – Jesse
你介意解釋這是如何工作的嗎?我很感興趣。 –
感謝您的回答。如果你打電話給眨眼光標模式,但是按預期工作,它會中斷。:) – Jesse
你介意在什麼時候中斷? – Thomas