Skip to content

Evil makes hidden cursor reappear on window configuration changes #592

Description

@TheBB

Originally reported by: Vasilij Schneidermann (Bitbucket: wasamasa, GitHub: wasamasa)


I wrote a package that hides the cursor by setting cursor-type to nil. This works initially, however changing the window configuration restores it because Evil has evil-refresh-cursor in window-configuration-change-hook. The comment above suggests it should just be changing the cursor color...

See also zone-nyan#5.


Activity

  1. TheBB commented on Nov 19, 2015

    @TheBB
    MemberAuthor

    Original comment by Frank Fischer (Bitbucket: lyro, GitHub: lyro):


    Not sure how to fix this. IIRC the problem is that some cursor attributes are frame specific, not buffer specific, and hence Evil somehow effects cursors in other windows as well. Certainly this could be done better ...

  2. TheBB commented on Dec 28, 2015

    @TheBB
    MemberAuthor

    Original comment by Vasilij Schneidermann (Bitbucket: wasamasa, GitHub: wasamasa):


    I've settled for a workaround. blink-cursor-mode uses internal-show-cursor to hide and display the cursor in regular intervals. I'll still leave this open though because the semantics of cursor-type and internal-show-cursor are different.

  3. rosetail commented on Feb 10, 2022

    @rosetail

    I'm not sure if this will help anyone, but I found a way to hide the cursor in evil mode. I tried this as a last-ditch effort and I have now idea how or why this works. I've only tested in org-agenda using setq-local, so your milage may vary. But before setting cursor-type to nil, set evil-default-cursor to '(ignore).

  4. archiif commented on May 5, 2022

    @archiif

    You can also do:

    (setq-local evil-normal-state-cursor '(bar . 0))

    You might also need to set other evil-*-state-cursor variables, depending on what you want to do.

  5. real-or-random commented on Mar 31, 2026

    @real-or-random
    Contributor
    ;; Helpers for hiding the cursor in evil.
    (defun >evil-nil-cursor-spec ()
      (setq cursor-type nil))
    (defun >evil-hide-cursor-local ()
      "Hide the cursor in the current buffer."
      (interactive)
      (setq-local
       evil-default-cursor #'>evil-nil-cursor-spec
       ;; Add more states here as desired
       evil-normal-state-cursor #'>evil-nil-cursor-spec
       evil-motion-state-cursor #'>evil-nil-cursor-spec))

    edit: Or, use this much simpler alternative:

    (setq-local evil-default-cursor (list nil)
                ;; Add more states here as desired
                evil-normal-state-cursor (list nil)
                evil-motion-state-cursor (list nil))
  6. added a commit that references this issue on Apr 27, 2026
    006dc3e
  7. added a commit that references this issue on Jun 2, 2026
    df13e78
  8. added a commit that references this issue on Jun 2, 2026
    ba04ab8
  9. perryprog commented on Jun 2, 2026

    @perryprog

    @tomdl89 this fix seems to cause the block cursor to be invisible in insert normal mode in a bare config (nextstep, macOS). For me I'm seeing evil-refresh-cursor first call evil-set-cursor with t, but the second evil-set-cursor call is then nil (from (evil-state-property 'normal :cursor t)).

  10. real-or-random commented on Jun 2, 2026

    @real-or-random
    Contributor

    @tomdl89 this fix seems to cause the block cursor to be invisible in insert mode in a bare config (nextstep, macOS). For me I'm seeing evil-refresh-cursor first call evil-set-cursor with t, but the second evil-set-cursor call is then nil (from (evil-state-property 'normal :cursor t)).

    In insert mode or in normal mode? I see that this would be a problem in normal mode. So far, :cursor nil (which is probably implicitly set if no :cursor is given) was used to indicate that a cursor should use the default cursor. But now that nil actually means "no cursor", we don't have a value for indicating "use the default cursor". We'd probably need something like unspecified in faces.

    Maybe it's easier to revert this and simply change the docs to say that (list nil) should be passed for "no cursor" (instead of just nil).

    Sorry I missed this. I use doom Emacs which has explicit settings for all states.

  11. perryprog commented on Jun 2, 2026

    @perryprog

    Oops, yes, the cursor is only invisible in normal (and IIRC visual mode)—my mistake.

  12. tomdl89 commented on Jun 2, 2026

    @tomdl89
    Member

    I've reverted this. My mistake for not checking before merging. I don't have much time for evil these days but blindly merging PRs is admittedly not a good solution. @real-or-random if you want to make a new PR that actually fixes this properly, and you can thoroughly test it in vanilla evil, not just Doom, then go ahead.

  13. reopened this on Jun 2, 2026
  14. real-or-random commented on Jun 2, 2026

    @real-or-random
    Contributor

    @real-or-random if you want to make a new PR that actually fixes this properly, and you can thoroughly test it in vanilla evil, not just Doom, then go ahead.

    Sorry for not testing in vanilla Emacs. I didn't expect that this could cause trouble here.

    Given the maturity of the codebase, I tend to think that it's best to simply change the docs to match the actual behavior. This won't require touching actual code and so no testing will be required. See #2026.

  15. added 2 commits that reference this issue on Jun 2, 2026
    b2bbeaa
    3cc84d8
  16. added a commit that references this issue on Jun 3, 2026
    3b678a2
  17. tomdl89 commented on Jun 3, 2026

    @tomdl89
    Member

    Agreed, that seems like a sensible approach. Thanks @real-or-random !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions