emacsemacs-faces

Can't change cursor color in emacsclient


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

Solution

  • 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.