Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading theme via package system and user initialization #170

Open
ghost opened this issue Sep 4, 2015 · 0 comments
Open

Loading theme via package system and user initialization #170

ghost opened this issue Sep 4, 2015 · 0 comments

Comments

@ghost
Copy link

ghost commented Sep 4, 2015

I recently went through the process of installing this package via package-install and then loading it directly through my ~/.emacs.d/init.el (a.k.a. ~/.emacs). I finally got it to work, and I thought it would be useful to include information about it in the README. (This is for Emacs 24.5.1.)

Here's what I did.

  • Install color-theme-solarized via the package system from MELPA. I won't go through that process here. I'll assume this is known.
  • Set up the after-make-frame-functions hook as already specified.
  • Add a function to after-init-hook to turn it on. Something like this in your ~/.emacs.d/init.el:
(defun personal/after-init-hook-function ()
  (when (memq 'color-theme-solarized package-activated-list)
    (load-theme 'solarized t)))

(add-hook 'after-init-hook 'personal/after-init-hook-function)

Technically speaking, you can also do this:

(require 'package)
(package-initialize)
(load-theme 'solarized t)

The only caveat with this second approach is outlined in the Emacs manual under Package Installation:

The reason automatic package loading occurs after loading the init file is that user options only receive their customized values after loading the init file, including user options which affect the packaging system.

It looks like the "accepted" way to load and use packages is lazily, which means making liberal use of the after-init-hook. I don't know if this is really what was intended, but packages are not available when your init.el is processed, so you either have to (a) ensure all customization is done through customize; (b) don't use customize for much of anything; (c) run package-initialize yourself (which may make some customizations not work); (d) load the packages and apply code-based customizations after the packages are loaded by Emacs, which is after the init.el is processed. (Hey, let's just rewrite Emacs in Haskell to solve this problem!(*))

I've used this to deal with all the stuff I've installed through packages and have migrated my code-based customizations accordingly. It appears to work. (What's odd is that, essentially, you end up having the after-init-hook load some other Elisp file to do the code-based customizations for packages.)

I have a feeling I'm missing something, but this doesn't feel like a horrible hack so I'm suggesting it for the time being. If I come across something else, I'll provide more information.

(*) No. And shame on you for even entertaining the idea for a number of picoseconds greater than 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants