Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cursor colour #1910

Merged
merged 1 commit into from
Jun 18, 2024
Merged

Fix cursor colour #1910

merged 1 commit into from
Jun 18, 2024

Conversation

fnussbaum
Copy link
Contributor

@fnussbaum fnussbaum commented Jun 15, 2024

Fixes #502, fixes #1835. Refreshing the cursor when changing the evil state is
only needed (or almost only, see below) when the current buffer is displayed in the
selected window. If this is not the case, and the buffer is only displayed or
its window selected at some later point in time, then evil-refresh-cursor will
be called as part of the window-configuration-change-hook or as advice to
select-window.

However, this introduces the following tiny (and maybe acceptable?) regression:
When doing something like

(with-current-buffer some-buffer-displayed-in-another-window
  (some-evil-state-with-a-different-cursor-type))

the cursor will not be refreshed in the other window before selecting it. The
cursor colour should indeed not be refreshed, because it is defined for the
whole frame; however, the cursor type should in principle be changed, as it is
defined per buffer and also defines the shape of the cursor in non-selected
windows.

There exist different ways to also handle this case, but they mostly seem ugly
or needlessly complicated to me. I think the most elegant way to fix this would
involve implementing per-buffer cursor colours in Emacs (as suggested in
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=24153d). What do you think?

@fnussbaum fnussbaum marked this pull request as draft June 15, 2024 20:31
@fnussbaum fnussbaum changed the title Fix cursor colour Fix cursor colour in some cases Jun 16, 2024
Fixes emacs-evil#502, fixes emacs-evil#1835. Refreshing the cursor when changing the evil state is
only needed (or almost only, see below) when the current buffer is displayed in the
selected window. If this is not the case, and the buffer is only displayed or
its window selected at some later point in time, then `evil-refresh-cursor` will
be called as part of the `window-configuration-change-hook` or as advice to
`select-window`.

However, this introduces the following tiny (and maybe acceptable?) regression:
When doing something like
```elisp
(with-current-buffer (some-buffer-displayed-in-another-window)
  (some-evil-state-with-a-different-cursor-type))
```
the cursor will not be refreshed in the other window before selecting it. The
cursor colour should indeed not be refreshed, because it is defined for the
whole frame; however, the cursor type should in principle be changed, as it is
defined per buffer and also defines the shape of the cursor in non-selected
windows.

There exist different ways to also handle this case, but they mostly seem ugly
or needlessly complicated to me. I think the most elegant way to fix this would
involve implementing per-buffer cursor colors in Emacs (as suggested in
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=24153d). What do you think?
@fnussbaum fnussbaum changed the title Fix cursor colour in some cases Fix cursor colour Jun 16, 2024
@fnussbaum fnussbaum marked this pull request as ready for review June 16, 2024 13:53
@tomdl89 tomdl89 merged commit d7c0f8f into emacs-evil:master Jun 18, 2024
12 checks passed
@tomdl89
Copy link
Member

tomdl89 commented Jun 18, 2024

Thanks for the PR @fnussbaum I think this is a net improvement. Hopefully we won't see a rush of complaints wrt the regression you mentioned. I'm happy to take the risk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cursor color does not persist Cursor is not refreshed in some cases
2 participants