how to change the cursor color on emacs
Try this:
(setq default-frame-alist
'((cursor-color . "palegoldenrod")))
If you want to preserve the other values in default-frame-alist
you can us Mark's suggestion:
(add-to-list 'default-frame-alist '(cursor-color . "palegoldenrod"))
None of above worked for me, so I did a little research on my own. From EmacsWiki:
14.20 Displaying the Cursor
On a text terminal, the cursor's appearance is controlled by the terminal, largely out of the control of Emacs. Some terminals offer two different cursors: a “visible” static cursor, and a “very visible” blinking cursor. By default, Emacs uses the very visible cursor, and switches to it when you start or resume Emacs. If the variable visible-cursor is nil when Emacs starts or resumes, it uses the normal cursor.
On a graphical display, many more properties of the text cursor can be altered. To customize its color, change the :background attribute of the face named cursor (see Face Customization). (The other attributes of this face have no effect; the text shown under the cursor is drawn using the frame's background color.) To change its shape, customize the buffer-local variable cursor-type; possible values are box (the default), hollow (a hollow box), bar (a vertical bar), (bar . n) (a vertical bar n pixels wide), hbar (a horizontal bar), (hbar . n) (a horizontal bar n pixels tall), or nil (no cursor at all).
To disable cursor blinking, change the variable blink-cursor-mode to nil (see Easy Customization), or add the line (blink-cursor-mode 0) to your init file. Alternatively, you can change how the cursor looks when it “blinks off” by customizing the list variable blink-cursor-alist. Each element in the list should have the form (on-type . off-type); this means that if the cursor is displayed as on-type when it blinks on (where on-type is one of the cursor types described above), then it is displayed as off-type when it blinks off.
Some characters, such as tab characters, are “extra wide”. When the cursor is positioned over such a character, it is normally drawn with the default character width. You can make the cursor stretch to cover wide characters, by changing the variable x-stretch-cursor to a non-nil value.
The cursor normally appears in non-selected windows as a non-blinking hollow box. (For a bar cursor, it instead appears as a thinner bar.) To turn off cursors in non-selected windows, change the variable cursor-in-non-selected-windows to nil.
To make the cursor even more visible, you can use HL Line mode, a minor mode that highlights the line containing point. Use M-x hl-line-mode to enable or disable it in the current buffer. M-x global-hl-line-mode enables or disables the same mode globally.
So here is the way to do it:
1. M-x customize-face
, enter
2. cursor
enter
3. choose the background color of you liking.
4. click on state, save for future sessions.
Screenshots here:
If you are running a recent version of emacs you can use:
; Set cursor color to white
(set-cursor-color "#ffffff")
Instead of #ffffff
you can use any color you like. For a list of hex code google Says: http://www.tayloredmktg.com/rgb/
Maybe you like this one... the following code changes the cursor color on each blink. Just eval code and its running:
; Using in Emacs 24.0
(defvar blink-cursor-colors (list "#92c48f" "#6785c5" "#be369c" "#d9ca65")
"On each blink the cursor will cycle to the next color in this list.")
(setq blink-cursor-count 0)
(defun blink-cursor-timer-function ()
"Zarza wrote this cyberpunk variant of timer `blink-cursor-timer'.
Warning: overwrites original version in `frame.el'.
This one changes the cursor color on each blink. Define colors in `blink-cursor-colors'."
(when (not (internal-show-cursor-p))
(when (>= blink-cursor-count (length blink-cursor-colors))
(setq blink-cursor-count 0))
(set-cursor-color (nth blink-cursor-count blink-cursor-colors))
(setq blink-cursor-count (+ 1 blink-cursor-count))
)
(internal-show-cursor nil (not (internal-show-cursor-p)))
)
Note that this code replaces the emacs function 'blink-cursor-timer-function' from 'frame.el'.