evil-mode has led my cursor to the dark side!
Hi, evil-mode is so evil that it has stained my cursor black, as black as the soul of evil-mode! I upgraded to Emacs 24.1 from 23.4, and I noticed a new Themes feature, so I set up the "tsdh-dark" theme, only to find that my cursor is now black, even though the background color is a dark gray. At first I thought some of my old customizations might have been conflicting with the theming, but after cleaning up my ~/.emacs as follows, I found the cursor remained black. ; specify packages for el-get (setq my-packages '(column-marker cython-mode evil evil-surround haskell-mode python-mode undo-tree)) (setq evil-want-C-u-scroll t) ; load el-get (add-to-list 'load-path "~/.emacs.d/el-get/el-get") (unless (require 'el-get nil t) (with-current-buffer (url-retrieve-synchronously "https://raw.github.com/dimitri/el-get/master/el-get-install.el") (end-of-buffer) (eval-print-last-sexp))) (el-get 'sync my-packages) ; evil settings (evil-mode 1) (define-key evil-normal-state-map ",l" 'whitespace-mode) ; column markers (add-hook 'python-mode-hook '(lambda () (interactive) (column-marker-1 73) (column-marker-2 80))) (add-hook 'rst-mode-hook '(lambda () (interactive) (column-marker-1 73))) ; load Japanese input (require 'mozc) (setq default-input-method "japanese-mozc") ; setup smtpmail ; [redacted] ; start daemon (server-start) (custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(custom-enabled-themes (quote (tsdh-dark))) '(evil-want-C-u-scroll t) '(file-precious-flag t) '(indent-tabs-mode nil)) (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(default ((t (:width semi-condensed))))) Then I suspected that the theme was just badly designed. But on a hunch, I tried commenting out the line "(evil-mode 1)", and restarted Emacs. The cursor was white! And running "M-x evil-mode" made it black again. How can I fix this? Is it a bug in evil-mode, or am I just doing something wrong? -Keshav
On Mon, Jul 16, 2012 at 10:12:22AM +0800, Keshav Kini wrote:
How can I fix this? Is it a bug in evil-mode, or am I just doing something wrong?
I'm not 100% sure, but google for the "evil-default-cursor" variable, and also maybe "set-cursor-color". Actually, here is a very relevant link http://comments.gmane.org/gmane.emacs.vim-emulation/919. -Linus
Hi Keshav, On Mon, Jul 16 2012 (04:12), Keshav Kini <[email protected]> wrote:
evil-mode is so evil that it has stained my cursor black, as black as the soul of evil-mode!
[...]
Then I suspected that the theme was just badly designed. But on a hunch, I tried commenting out the line "(evil-mode 1)", and restarted Emacs. The cursor was white! And running "M-x evil-mode" made it black again.
Yes, Evil is the culprit in a way. Here is the relevant code: (defcustom evil-default-cursor (list (or (frame-parameter nil 'cursor-color) "black") t) ... Which is correct (and keep in mind black is also emacs' default color), but is only evaluated once.
How can I fix this? Is it a bug in evil-mode, or am I just doing something wrong?
As a workaround: Load the theme before you load evil (not just before enabling!). or Set `evil-default-cursor' yourself (Here[1] is a truly evil cursor function). For a less makeshift version I'd suggest either 1) change the default value of `evil-default-cursor' to nil and evaluate the code above instead always if `evil-default-cursor' is nil 2) advise load-theme and update `evil-default-cursor' But 2. would only fix color themes. What do you think? Frank? Vegard? Michael Footnotes: [1] https://github.com/cofi/dotfiles/blob/master/emacs.d/config/cofi-evil.el#L25...
On 2012-07-16, Michael Markert <[email protected]> wrote:
For a less makeshift version I'd suggest either
1) change the default value of `evil-default-cursor' to nil and evaluate the code above instead always if `evil-default-cursor' is nil
I would go with this, setting the default value to either nil or t (the latter should enforce the current frame-parameter value, so probably nil is better). To be honest, I have no idea why we've once set the default value to "black", which is certainly a bad idea when dealing with color themes. So please check if something strange happens I'm currently not aware of, otherwise we're going to change the default. Frank
On 2012-07-17 09:03 +0200, Frank Fischer wrote:
On 2012-07-16, Michael Markert wrote:
change the default value of `evil-default-cursor' to nil and evaluate the code above instead always if `evil-default-cursor' is nil
To be honest, I have no idea why we've once set the default value to "black", which is certainly a bad idea when dealing with color themes.
The `evil-default-cursor' variable is initialized to the current cursor color when Evil is loaded. This is to ensure that if another state changes the color, it is changed back by Normal state. http://article.gmane.org/gmane.emacs.vim-emulation/919/ The solution is simple enough: set up the desired theme before loading Evil. Alternatively, if you are certain you won't customize the states to change the cursor color, add (setq evil-default-cursor t). -- Vegard
On 2012-07-17, Vegard Øye <[email protected]> wrote:
The `evil-default-cursor' variable is initialized to the current cursor color when Evil is loaded. This is to ensure that if another state changes the color, it is changed back by Normal state.
http://article.gmane.org/gmane.emacs.vim-emulation/919/
The solution is simple enough: set up the desired theme before loading Evil. Alternatively, if you are certain you won't customize the states to change the cursor color, add (setq evil-default-cursor t).
Fair enough. But I wonder if there is always something like "a current color", or if it is appropriate in frames. I often have frames with different colors (and I change them on run-time to whichever is appropriate for the current mode) or X and terminal frames, which may be confusing when all those frames run in the same instance (emacsclient). So the question is if there is a better way to "reset" the cursor correctly (to normal-state or something else) without falling back to some mysterious default, right? Not that I knew how to do this ... ;) Frank
participants (5)
-
Frank Fischer -
Keshav Kini -
Linus Arver -
Michael Markert -
Vegard Øye