1

This is a newbie question.

I'd like to have a red cursor with a width of 4. This code doesn't work:

(setf cursor-type '(bar . 4))
(set-cursor-color "#FF0000")

how can i correct this to display a red cursor with a width of 4?

1 Answer 1

3

Since cursor-type is a buffer-local variable, if you use setf (or setq) you only change its value in the temporary buffer used while reading the init file (ref.). When a variable's doc string says "Automatically becomes buffer-local when set" it means you have to use setq-default to change it. This works for me

(setq-default cursor-type '(bar . 4))
(set-cursor-color "#FF0000") ; You can also use ‘"red"’.

From the comments: You can change the shape of the cursor in unselected windows by setting cursor-in-non-selected-windows, for example (setq-default cursor-in-non-selected-windows '(bar . 1)).

2
  • This is great except I can no longer can distinguish between two cursors in two different emacs windows. I can't distinguish which is current buffer, ie, the buffer in focus. Both are red. Is there a way I can hide the inactive cursor and make it invisible? Or maybe just make it light grey? Commented Feb 13, 2021 at 16:58
  • 1
    @WickedJargon You can change the shape of the cursor in the unselected windows by changing cursor-in-non-selected-windows, for example (setq-default cursor-in-non-selected-windows '(bar . 1)), or you can make it invisible by setting the variable to nil (see C-h v cursor-in-non-selected-windows for all the options). Regarding the color, I don't know how make Emacs use a different one for the unselected windows' cursor. Maybe How do I change the cursor face per buffer? is of help? Commented Feb 13, 2021 at 17:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.