Frage

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
War es hilfreich?

Lösung

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.

Andere Tipps

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"`)

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.

This worked for me :

(setq evil-default-cursor t) ;; Now evil takes the default cursors 
(set-cursor-color "white") ;; Set it to white
(set-mouse-color "white") ;; Same

I also have the very same issue, for years now.

In my case I do:

M-x
set-cursor-color
"white"<ENTER>

That works for me but I have to do this everytime, which sux..

Back in my old workplace I had this solved but I don't have the init.el that I used to have in my old workplace and now I need to figure this out all over again, hopefully someone in here will figure this out before me.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top