如何让Emacs中的光标像心跳一样闪烁。就像笔记本电脑前面板上的LED在计算机挂起时一样。
有一个名为blink-cursor-alist
的变量控制光标的闪烁,但我不知道如何使用它来满足我的要求。
这是否可能?
heartbeat-cursor-colors
以获得不同的色调或其变化。(require 'cl)
(require 'color)
(defvar heartbeat-fps 16)
(defvar heartbeat-period 5)
(defun heartbeat-range (from to cnt)
(let ((step (/ (- to from) (float cnt))))
(loop for i below cnt collect (+ from (* step i)))))
(defun heartbeat-cursor-colors ()
(let ((cnt (* heartbeat-period heartbeat-fps)))
(mapcar (lambda (r)
(color-rgb-to-hex r 0 0))
(nconc (heartbeat-range .2 1 (/ cnt 2))
(heartbeat-range 1 .2 (/ cnt 2))))))
(defvar heartbeat-cursor-timer nil)
(defvar heartbeat-cursor-old-color)
(define-minor-mode heartbeat-cursor-mode
"Change cursor color with the heartbeat effect."
nil "" nil
:global t
(when heartbeat-cursor-timer
(cancel-timer heartbeat-cursor-timer)
(setq heartbeat-cursor-timer nil)
(set-face-background 'cursor heartbeat-cursor-old-color))
(when heartbeat-cursor-mode
(setq heartbeat-cursor-old-color (face-background 'cursor)
heartbeat-cursor-timer
(run-with-timer
0 (/ 1 (float heartbeat-fps))
(lexical-let ((colors (heartbeat-cursor-colors)) tail)
(lambda ()
(setq tail (or (cdr tail) colors))
(set-face-background 'cursor (car tail))))))))
blink-cursor-mode
和blink-matching-open
。
第一个看起来正确。描述说:“切换闪烁光标模式”。<menu-bar> <options> <blink-cursor-mode>
。
因此,我猜想该选项位于菜单中的某个位置,也许在“选项”下面。
我打开“选项”菜单,它就在那里:“闪烁光标”,带有复选框。M-x customize-option
,然后blink-cursor-mode
。这使我可以切换值,并将其保存供将来使用。blink-cursor-interval
的变量。您可以使用M-x customize-variable
,然后blink-cursor-interval
来设置间隔。变量blink-cursor-alist
将关闭状态光标类型匹配到打开状态光标类型,与闪烁速度无关。
heartbeat-cursor-timer
设置为nil
-(defvar heartbeat-cursor-timer nil) - ajejeheartbeat-cursor-timer
。 - user4815162342