GNU bug report logs - #24153
25.1; Feature request: per-buffer cursor-color variable

Previous Next

Package: emacs;

Reported by: Tej Chajed <tchajed <at> mit.edu>

Date: Thu, 4 Aug 2016 15:28:02 UTC

Severity: wishlist

Found in version 25.1

To reply to this bug, email your comments to 24153 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#24153; Package emacs. (Thu, 04 Aug 2016 15:28:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Tej Chajed <tchajed <at> mit.edu>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 04 Aug 2016 15:28:02 GMT) Full text and rfc822 format available.

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

From: Tej Chajed <tchajed <at> mit.edu>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.1; Feature request: per-buffer cursor-color variable
Date: Thu, 4 Aug 2016 11:08:12 -0400
Currently there's a per-buffer cursor-type variable that is respected
per window and a single cursor-color variable that applies to the
entire frame.

Evil emulates a per-window cursor color in order to have the cursor
color of the active window reflect the buffer state (eg,
distinguishing insert and normal mode). It does so by advising
set-window and calling set-cursor-color if necessary; this can lead to
slowdowns when code calls set-window repeatedly (eg, through
with-selected-window).

It seems like the right way for evil to manage the cursor color is to
have an analogous per-buffer cursor-color variable natively provided
by emacs. Is this a doable feature?

Thanks!
Tej




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24153; Package emacs. (Thu, 04 Aug 2016 17:15:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tej Chajed <tchajed <at> mit.edu>
Cc: 24153 <at> debbugs.gnu.org
Subject: Re: bug#24153: 25.1; Feature request: per-buffer cursor-color variable
Date: Thu, 04 Aug 2016 20:13:56 +0300
> From: Tej Chajed <tchajed <at> mit.edu>
> Date: Thu, 4 Aug 2016 11:08:12 -0400
> 
> It seems like the right way for evil to manage the cursor color is to
> have an analogous per-buffer cursor-color variable natively provided
> by emacs. Is this a doable feature?

I don't see up front why not.  Patches welcome.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24153; Package emacs. (Fri, 05 Aug 2016 01:22:02 GMT) Full text and rfc822 format available.

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

From: npostavs <at> users.sourceforge.net
To: Tej Chajed <tchajed <at> mit.edu>
Cc: 24153 <at> debbugs.gnu.org
Subject: Re: bug#24153: 25.1; Feature request: per-buffer cursor-color variable
Date: Thu, 04 Aug 2016 21:21:17 -0400
Tej Chajed <tchajed <at> mit.edu> writes:
>
> Evil emulates a per-window cursor color in order to have the cursor
> color of the active window reflect the buffer state (eg,
> distinguishing insert and normal mode). It does so by advising
> set-window and calling set-cursor-color if necessary; this can lead to
> slowdowns when code calls set-window repeatedly (eg, through
> with-selected-window).

There's no `set-window' function, did you mean `select-window'?  I find
in the docstring for that function:

    Selections that "really count" are those causing a visible change in
    the next redisplay of WINDOW’s frame and should be always recorded.
    So if you think of running a function each time a window gets
    selected put it on ‘buffer-list-update-hook’.

Perhaps using ‘buffer-list-update-hook’ instead of advising
`select-window' would help?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24153; Package emacs. (Fri, 05 Aug 2016 02:18:01 GMT) Full text and rfc822 format available.

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

From: Tej Chajed <tchajed <at> mit.edu>
To: npostavs <at> users.sourceforge.net
Cc: 24153 <at> debbugs.gnu.org
Subject: Re: bug#24153: 25.1; Feature request: per-buffer cursor-color variable
Date: Thu, 4 Aug 2016 22:17:04 -0400
On Thu, Aug 4, 2016 at 9:21 PM,  <npostavs <at> users.sourceforge.net> wrote:
> Tej Chajed <tchajed <at> mit.edu> writes:
>>
>> Evil emulates a per-window cursor color in order to have the cursor
>> color of the active window reflect the buffer state (eg,
>> distinguishing insert and normal mode). It does so by advising
>> set-window and calling set-cursor-color if necessary; this can lead to
>> slowdowns when code calls set-window repeatedly (eg, through
>> with-selected-window).
>
> There's no `set-window' function, did you mean `select-window'?

Yes, my mistake - the advice is on select-window.

>
> Perhaps using ‘buffer-list-update-hook’ instead of advising
> `select-window' would help?

I haven't fully debugged this alternative, but it doesn't seem to
work. company-coq still uses save-window-excursion in
company-coq-ask-prover, which triggers the buffer-list-update-hook. In
addition, even with company-coq disabled this somehow doesn't call
evil-refresh-cursor enough; starting from insert mode, after the first
proof command, the color gets stuck on the normal mode color, and then
doesn't change until some other buffer list update.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24153; Package emacs. (Fri, 05 Aug 2016 02:50:01 GMT) Full text and rfc822 format available.

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

From: Clément Pit--Claudel <clement.pit <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org, npostavs <at> users.sourceforge.net
Subject: Re: bug#24153: 25.1; Feature request: per-buffer cursor-color variable
Date: Thu, 4 Aug 2016 22:49:18 -0400
[Message part 1 (text/plain, inline)]
On 2016-08-04 21:21, npostavs <at> users.sourceforge.net wrote:
> Perhaps using ‘buffer-list-update-hook’ instead of advising
> `select-window' would help?

Hmmm. I don't think that would work.

Assume there are two windows, one showing a buffer in evil's normal editing mode, and one showing a buffer in evil's edit mode.  If the user has configured evil to show the normal-mode cursor in green and the insert-mode cursor in purple, then evil needs to change the cursor color every time the user switches between these two windows, and (I don't think that) buffer-list-update-hook won't be sufficient for that.

Cheers,
Clément.

[signature.asc (application/pgp-signature, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24153; Package emacs. (Fri, 05 Aug 2016 16:38:01 GMT) Full text and rfc822 format available.

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

From: martin rudalics <rudalics <at> gmx.at>
To: Tej Chajed <tchajed <at> mit.edu>, npostavs <at> users.sourceforge.net
Cc: 24153 <at> debbugs.gnu.org
Subject: Re: bug#24153: 25.1; Feature request: per-buffer cursor-color variable
Date: Fri, 05 Aug 2016 18:37:11 +0200
>>> Evil emulates a per-window cursor color in order to have the cursor
>>> color of the active window reflect the buffer state (eg,
>>> distinguishing insert and normal mode). It does so by advising
>>> set-window and calling set-cursor-color if necessary; this can lead to
>>> slowdowns when code calls set-window repeatedly (eg, through
>>> with-selected-window).
>>
>> There's no `set-window' function, did you mean `select-window'?
>
> Yes, my mistake - the advice is on select-window.
>
>>
>> Perhaps using ‘buffer-list-update-hook’ instead of advising
>> `select-window' would help?
>
> I haven't fully debugged this alternative, but it doesn't seem to
> work. company-coq still uses save-window-excursion in
> company-coq-ask-prover, which triggers the buffer-list-update-hook.

Please tell us more about where and why ‘buffer-list-update-hook’
doesn't work in any of your use cases.  From what you say here you
expect ‘save-window-excursion’ to _not_ run ‘buffer-list-update-hook’.
Is that correct?

> In
> addition, even with company-coq disabled this somehow doesn't call
> evil-refresh-cursor enough; starting from insert mode, after the first
> proof command, the color gets stuck on the normal mode color, and then
> doesn't change until some other buffer list update.

But IIUC you do not set the buffer of any window in these steps, so why
would you expect ‘buffer-list-update-hook’ to run?

martin






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24153; Package emacs. (Fri, 05 Aug 2016 16:38:02 GMT) Full text and rfc822 format available.

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

From: martin rudalics <rudalics <at> gmx.at>
To: Clément Pit--Claudel <clement.pit <at> gmail.com>, 
 24153 <at> debbugs.gnu.org, npostavs <at> users.sourceforge.net
Subject: Re: bug#24153: 25.1; Feature request: per-buffer cursor-color variable
Date: Fri, 05 Aug 2016 18:37:18 +0200
> Assume there are two windows, one showing a buffer in evil's normal
> editing mode, and one showing a buffer in evil's edit mode.  If the
> user has configured evil to show the normal-mode cursor in green and
> the insert-mode cursor in purple, then evil needs to change the cursor
> color every time the user switches between these two windows, and (I
> don't think that) buffer-list-update-hook won't be sufficient for
> that.

This would be a bug.  ‘select-window’ should always run
‘buffer-list-update-hook’ when NORECORD is nil.

martin





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24153; Package emacs. (Sat, 06 Aug 2016 02:00:03 GMT) Full text and rfc822 format available.

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

From: Clément Pit--Claudel <clement.pit <at> gmail.com>
To: martin rudalics <rudalics <at> gmx.at>, 24153 <at> debbugs.gnu.org,
 npostavs <at> users.sourceforge.net
Subject: Re: bug#24153: 25.1; Feature request: per-buffer cursor-color variable
Date: Fri, 5 Aug 2016 21:59:35 -0400
[Message part 1 (text/plain, inline)]
On 2016-08-05 12:37, martin rudalics wrote:
>> Assume there are two windows, one showing a buffer in evil's normal
>> editing mode, and one showing a buffer in evil's edit mode.  If the
>> user has configured evil to show the normal-mode cursor in green and
>> the insert-mode cursor in purple, then evil needs to change the cursor
>> color every time the user switches between these two windows, and (I
>> don't think that) buffer-list-update-hook won't be sufficient for
>> that.
> 
> This would be a bug.  ‘select-window’ should always run
> ‘buffer-list-update-hook’ when NORECORD is nil.

I see; thanks for clarifying!


[signature.asc (application/pgp-signature, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24153; Package emacs. (Sat, 06 Aug 2016 02:11:02 GMT) Full text and rfc822 format available.

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

From: Clément Pit--Claudel <clement.pit <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#24153: 25.1; Feature request: per-buffer cursor-color variable
Date: Fri, 5 Aug 2016 22:10:07 -0400
[Message part 1 (text/plain, inline)]
On 2016-08-04 22:17, Tej Chajed wrote:
>>> Perhaps using ‘buffer-list-update-hook’ instead of advising
>>> `select-window' would help?
>
> I haven't fully debugged this alternative, but it doesn't seem to
> work. company-coq still uses save-window-excursion in
> company-coq-ask-prover, which triggers the buffer-list-update-hook. 

IIRC I added this save-window-excursion call to work a Proof General issue, back when I didn't know much about PG.  Now that I have commit rights there, I could probably move the fix upstream and remove the save-window-excursion call.

Clément.

[signature.asc (application/pgp-signature, attachment)]

This bug report was last modified 9 years and 32 days ago.

Previous Next


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