GNU bug report logs - #77224
[PATCH] New minor mode 'cursor-indicators-mode'

Previous Next

Package: emacs;

Reported by: Elijah Gabe Pérez <eg642616 <at> gmail.com>

Date: Sun, 23 Mar 2025 22:59:03 UTC

Severity: normal

Tags: patch

Full log


View this message in rfc822 format

From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
To: Rudolf Schlatte <rudi <at> constantly.at>
Cc: 77224 <at> debbugs.gnu.org
Subject: bug#77224: [PATCH] New minor mode 'cursor-indicators-mode'
Date: Tue, 25 Mar 2025 23:00:56 -0600
[Message part 1 (text/plain, inline)]
Rudolf Schlatte <rudi <at> constantly.at> writes:

> Juri Linkov <juri <at> 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:

>> #+begin_src 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")))))
>> #+end_src


>> Then I could replace:

>> #+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))))
>> #+end_src


>> with just

>> #+begin_src emacs-lisp
>> (setopt cursor-indicators '((repeat-in-progress   "blue")
>>                             (current-input-method "red3")
>>                             (overwrite-mode       'box)
>>                             (default              'bar)))
>> #+end_src

> 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.

#+begin_src elisp
  (setopt cursor-indicators-conditions '((use-region-p . "purple")))
#+end_src

[Message part 2 (text/html, inline)]
[Message part 3 (text/plain, inline)]

-- 
                                          - E.G via GNU Emacs and Org.

This bug report was last modified 64 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.