I made some changes in Emacs's colors and the only thing wrong now is the cursor that is black on black background and I will have to change that. What do I do?
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'.
None of above worked for me, so I did a little research on my own. From the Emacs Manual:
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:
M-x customize-face
, entercursor
enter- choose the background color of you liking.
- click on state, save for future sessions.
Screenshots here:
Apply and Save
button shown at the top of your screenshot. A bright red cursor for me. My matching paren indicator colors are too dark, and the color hides the (rainbow) parens, so all I see is two solid colored blocks. To change the matching parens color to something lighter (white for me), see here: emacs.stackexchange.com/a/76410 –
Lubricity mouse
for cursor
after M-x customize-face RET
–
Selig 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"))
default-frame-alist
usually contains some X specific staff (such as default frame size) already. Did you mean (add-to-list 'default-frame-alist '(cursor-color . "palegoldenrod"))
? –
Catsup default-frame-alist
on my build of Emacs seems to default to just ((menu-bar-lines . 1) (tool-bar-lines . 1))
- which wouldn't be sorely missed. Adjusting answer. –
Aporia If you use X window system, try out put something like this to .Xdefaults
:
*cursorColor: #ff7700
For me, setting the cursor color on init with the recommendation from the other answers wouldn't really work because of some possible interference with the themes and packages I was loading. My solution was to add the following instead:
(add-hook 'after-init-hook
(lambda () (run-with-timer 5 nil #'set-cursor-color "SystemRedColor")))
This solution makes it so that a call to set-cursor-color will only happen 5 seconds after init finishes, allowing enough time for all the other packages and theme changes to fully load.
You can use this for customize emacs colors:
(defun good-colors ()
(progn
;; Set cursor color
(set-cursor-color "Black")
(set-background-color "grey46")
(set-foreground-color "White")
(set-border-color "dark orange")
(set-mouse-color "dark orange")
))
(good-colors)
progn
wrapper in this instance (i.e. at the top level of a function). –
Octavalent There is also a command line option:
--cursor-color, -cr COLOR color of the Emacs cursor indicating point
Keep in mind if you are using iTerm2
you have to make changes on its settings, otherwise changes on the .emacs
config file does not take place.
Preferences => Profiles => Color => Cursor Colors
I added (set-face-attribute 'cursor nil :background "#A0F")
to my .emacs
file, making my cursor a nice violet color.
I'm not sure how critical version and system info are, but I'm running GNU Emacs 27.1 in GUI mode on Ubuntu 22.04.1 LTS. (Emacs 28.2 is available from the GNU website, so YMMV.)
© 2022 - 2024 — McMap. All rights reserved.
default-frame-alist
as suggested by @TreyJackson in his answer. – Strohbehn