If I run emacs --daemon
(in .xinitrc
or later) and then emacsclient -c
, newly created frame has black cursor color, regardless on colortheme or any other settings. More exactly, before I type anything, the cursor color is white (or other color), but with first keypresses it becomes black and cannot be changed via set-cursor-color
. Both default and my custom colorthemes are black, so it makes editing very uncomfortable.
If I run emacs
and M-x server-start
instead of emacs --daemon
then this problem does not appear. But this way I need to keep one emacs "main" frame and not kill it incidentally, this doesn't seem like a nice solution.
I have following block in .emacs.d/init.el
but it doesn't help:
(set-cursor-color "red")
(setq initial-frame-alist '((cursor-color . "red")))
(setq default-frame-alist '((cursor-color . "red")))
(add-hook 'window-setup-hook '(lambda () (set-cursor-color "red")))
(add-hook 'after-make-frame-functions '(lambda (f) (with-selected-frame f (set-cursor-color "red"))))
If I run M-x describe-face RET cursor
I get:
(...)
Defined in `faces.el'.
Family: unspecified
Foundry: unspecified
Width: unspecified
Height: unspecified
Weight: unspecified
Slant: unspecified
Foreground: unspecified
Background: black
Underline: unspecified
Overline: unspecified
Strike-through: unspecified
Box: unspecified
Inverse: unspecified
Stipple: unspecified
Font: unspecified
Fontset: unspecified
Inherit: unspecified
I believe that in recent Emacsen, using frame properties to set the cursor color is not the preferred method. So instead of using set-cursor-color
or initial-frame-alist
/ default-frame-alist
, try:
(set-face-background 'cursor "red")
Or, perhaps:
(set-face-attribute 'cursor nil :background "red"`)
Alright.. This issue can be resolved by adding
(setq default-frame-alist '((cursor-color . "white")))
though I don't understand why it was not a problem before.
See this forum thread.
Bwahahaha! I think no-one has posted a solution for the past 2 years because you are all EVIL emacs users!
Truth be told, I'm trying out evil-mode at the moment myself and I just solved this problem on my system. Put this in your .emacs file and smoke it:
'(evil-default-cursor (quote (t "white")))
I just opened a bug against the Evil repository in bitbucket.
For myself, I found that after the 6 years or so it took to really become proficient at emacs, the multi-key chords were hard on my tendons. Evil-mode may allow me to use emacs again, which is a good thing. As Benedict says (in the context of Functional Programming), "Some evil is often necessary to get work done." It seems that may apply to Emacs as well.
P.S. For anyone feels this answer is just DH0 or otherwise immature and inappropriate, the mostly tongue-in-cheek feud between Emacs and VI users has raged for years. Emacs has it's own Church of Emacs, VI has the video game, World War VI. So it is no surprise that the most successful port of VI keybindings to Emacs was named evil-mode (evil has the word VI in it). I like both editors and laud the evil developers who finally made VI keybindings work inside emacs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With