-
-
Save Eason0210/a5cc04731a17eeec388e22c2dc33d322 to your computer and use it in GitHub Desktop.
Emacs: change cursor color during active repeat-mode commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(let ((orig (default-value 'repeat-echo-function)) | |
rcol ccol in-repeat) | |
(setq | |
repeat-echo-function | |
(lambda (map) | |
(if orig (funcall orig map)) | |
(unless rcol (setq rcol (face-foreground 'error))) | |
(if map | |
(unless in-repeat ; new repeat sequence | |
(setq in-repeat t | |
ccol (face-background 'cursor)) | |
(set-frame-parameter nil 'my/repeat-cursor ccol)) | |
(setq in-repeat nil) | |
(set-frame-parameter nil 'my/repeat-cursor nil)) | |
(set-cursor-color (if map rcol ccol)))) | |
(add-function | |
:after after-focus-change-function | |
(let ((sym 'my/remove-repeat-cursor-color-on-focus-change)) | |
(defalias sym | |
(lambda () | |
(when in-repeat | |
(dolist (frame (frame-list)) | |
(when-let ((col (frame-parameter frame 'my/repeat-cursor))) | |
(with-selected-frame frame | |
(set-cursor-color col))))))) | |
sym))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment