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


Message #164 received at 77224 <at> debbugs.gnu.org (full text, mbox):

From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
To: Daniel Colascione <dancol <at> dancol.org>
Cc: mail <at> daniel-mendler.de, Eli Zaretskii <eliz <at> gnu.org>, 77224 <at> debbugs.gnu.org,
 juri <at> linkov.net
Subject: Re: bug#77224: [PATCH] New minor mode 'cursor-indicators-mode'
Date: Fri, 28 Mar 2025 18:40:36 -0600
[Message part 1 (text/plain, inline)]
Daniel Colascione <dancol <at> dancol.org> writes:

> The feature I'm proposing is higher-level than that.  For example, for
> my personal use, I have something that sits in pre-redisplay-function
> and scans all the windows for applying highlights based on current
> buffer and window selection.  I should have written this thing using the
> appropriate window configuration change hooks, but didn't, because I'm
> lazy and my approach is fast enough for me.

>     ;; Don't do this.

>     (defun window-highlight--pre-redisplay (_window)
>       (window-highlight--rescan-windows))

>     (add-function :after pre-redisplay-function
>        #'window-highlight--pre-redisplay))

> What I'd have wanted instead is something like this:

>   (run-when-changed
>       (list (selected-window) (selected-frame) (frame-focus-state))
>     #'window-highlight--rescan-windows)

> Here, we'd run window-highlight--rescan-windows only when one of its
> dependent conditions (e.g. selected frame) changed.  After any number of
> window and frame changes, we'd run window-highlight--rescan-windows
> *once*, immediately before its effects would become user-visible
> (e.g. just before redisplay, or after commands), and we wouldn't re-run
> it until one of its preconditions changed.

Can your proposal also handle whether user moves cursor?

Another reason why post-command-hook is used is mostly for run code
when user moves cursor position.

post-command-hook would run code even if user/cursor is idle and even
for every /(unrelated)/ function in background, which can lead to high
resource consumption.

I think having alternatives like this for specific commands (or actions)
could help reduce the use of post-command-hook.

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