Subject: bug#77224: [PATCH] New minor mode 'cursor-indicators-mode'

From: Juri Linkov <[email-masked]>
Date: Mon, 24 Mar 2025 09:35:38 +0200

> FWIW, I have this in my init file since forever:
>
> (setq my/set-cursor-color-color "")
> (setq my/set-cursor-color-buffer "")
> (defun my/set-cursor-color-according-to-mode ()
> "Change cursor color according to some minor modes."
> ;; set-cursor-color is somewhat costly, so we only call it when needed:
> (let ((color
> (if buffer-read-only "#8888FF"
> (if overwrite-mode "#000000"
> "#FF0000"))))
> (unless (and
> (string= color my/set-cursor-color-color)
> (string= (buffer-name) my/set-cursor-color-buffer))
> (set-cursor-color (setq my/set-cursor-color-color color))
> (setq my/set-cursor-color-buffer (buffer-name)))))
> (add-hook 'post-command-hook 'my/set-cursor-color-according-to-mode)

Cool.  Will it be possible to replace these settings in my init file
with the new package?

#+begin_src emacs-lisp
(defun my-change-cursor (&rest _)
  "Change cursor color and type depending on insertion mode and input method."
  (set-cursor-color
   (cond (repeat-in-progress   "blue")
         (current-input-method "red3")
         (t                    "black")))
  (setq-default cursor-type
   (cond (overwrite-mode       'box)
         (t                    'bar))))
(add-hook 'post-command-hook 'my-change-cursor t)

;; Also update the cursor on the repeat timer events:
(add-function :after repeat-echo-function #'my-change-cursor)
#+end_src