Rudolf Schlatte <rudi@constantly.at> writes:
Juri Linkov <juri@linkov.net> writes:
+*** New minor mode 'cursor-indicators-mode'
+This mode changes cursor appearance (color and/or type) to indicate
+different buffer states. This mode have cursor indicators for:
+- Overwrite mode
+- Read-only buffers
+- Repeat mode
+- Input method activation
What if users want to add more conditions?
Could you try to create only one defcustom that
contains a list of default conditions
plus a possible user-defined conditions.
For example:
#+beginsrc emacs-lisp
(defcustom cursor-indicators nil
:type `(alist :key-type
(choice :tag "Condition"
(const :tag "Overwrite mode" overwrite)
(const :tag "Read-only mode" read-only)
(const :tag "Repeat mode" repeat-in-progress)
(const :tag "Activated input method" input-method)
(function :tag "Matcher function")) ;; User-defined condition
:value-type
(choice
(const :tag "None (do not change cursor)" nil)
(color :tag "Color")
(choice :tag "Type"
(const :tag "Filled box" box)
(const :tag "Vertical bar" bar)
(const :tag "Horizontal bar" hbar)
(const :tag "Hollow box" hollow))
(cons :tag "Color and Type"
(choice :tag "Type"
(const :tag "Filled box" box)
(const :tag "Vertical bar" bar)
(const :tag "Horizontal bar" hbar)
(const :tag "Hollow box" hollow))
(color :tag "Color")))))
#+endsrc
Then I could replace:
#+beginsrc 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))))
#+endsrc
with just
#+beginsrc emacs-lisp
(setopt cursor-indicators '((repeat-in-progress "blue")
(current-input-method "red3")
(overwrite-mode 'box)
(default 'bar)))
#+endsrc
I set the following hooks, which makes the cursor unobtrusive while I'm
selecting text (C-SPC then moving cursor). Could this also fit in the
above framework?
(deactivate-mark-hook . (lambda () (setq cursor-type t)))
(activate-mark-hook . (lambda () (setq cursor-type 'bar)))
Yeah, you can set it as something like this.
(setopt cursor-indicators-conditions '((use-region-p . "⏺purple")))