1

As the last line in my .emacs file I have:

(load-theme 'manoj-dark)

When I start a fresh emacs window, changes like the background color (black) take effect; however, my cursor stays black (and invisible). To fix this, I end up typing M-xload-theme manoj-dark anyway. Why isn't the line in my emacs config taking effect?

Rainer Joswig
  • 136,269
  • 10
  • 221
  • 346
WorldsEndless
  • 1,493
  • 1
  • 15
  • 27
  • There are two optional arguments, have you tried the first one -- i.e., no-confirm? `(load-theme 'manoj-dark t)` The doc-string says: *This function is normally called through Customize when setting 'custom-enabled-themes'. If used directly in your init file, it should be called with a non-nil NO-CONFIRM argument, or after `custom-safe-themes' has been loaded.* – lawlist Jun 14 '14 at 17:19
  • Thanks for the suggestion; no dice, though. – WorldsEndless Jun 14 '14 at 17:21
  • Do you have a setting somewhere that might conflict -- e.g., `(set-cursor-color "white")`? You can do a word search of your third-party libraries (for `set-cursor-color`) and any other user configuration files. – lawlist Jun 14 '14 at 17:24
  • The other thing you can look for is something like this, which could be overriding your theme: `(custom-set-faces '(cursor ((t (:background "white")))) . . .` and also `(set-face-attribute 'cursor . . .` – lawlist Jun 14 '14 at 17:39
  • No results in either case. – WorldsEndless Jun 14 '14 at 17:40

2 Answers2

2

The problem had to do with using emacsclient (daemon). The key was to use the 'after-make-frame-functions hook.

(if (daemonp)
    (add-hook 'after-make-frame-functions
        (lambda (frame)
            (select-frame frame)
            (load-theme 'manoj-dark t)))
    (load-theme 'manoj-dark t))

See also https://stackoverflow.com/a/23668935/1542702

Community
  • 1
  • 1
WorldsEndless
  • 1,493
  • 1
  • 15
  • 27
0

Perhaps using after-init-hook would allow the theme load to happen after whatever has fiddled around with the caret colour during initialisation?

I've seen problems with package initialisations clashing over such things (smart-mode-line and a colour theme, in my case), and this helped me.

Something like the following, perhaps (note: untested):

(add-hook 'after-init-hook
          (lambda ()
            (load-theme 'manoj-dark)))

At worst case you might be able to use (run-with-timer ...) or (run-with-idle-timer ...) (again, untested), to arrange for theme load to happen a few seconds after the end of initialisation to simulate your manual workaround. It would be kludgey, though.