use-package icon indicating copy to clipboard operation
use-package copied to clipboard

`use-package` requires setting `custom-theme-load-path` when loading a local theme with `:load-path`

Open topikettunen opened this issue 4 years ago • 0 comments

Hi!

I noticed this weird issue on my setup which I'm pretty sure wasn't happening earlier.

Currently when I load my local theme with:

(use-package tok-theme
  :load-path "themes/tok-theme"
  :defer nil
  :if window-system
  :config
  (load-theme 'tok t))

It can't find the theme called tok. But when I add:

(use-package tok-theme
  :load-path "themes/tok-theme"
  :defer nil
  :if window-system
  ;; For some reason when I load my theme with use-package I need to set this explicitly.
  :init
  (add-to-list 'custom-theme-load-path "~/.emacs.d/themes/tok-theme")
  (load-theme 'tok t))

it finds it with no issue. I'm pretty sure that at one point for me adding that :load-path worked just fine when loading my theme.

There are also no issues when I load the theme with:

(add-to-list 'load-path "~/.emacs.d/themes/tok-theme")
(require 'tok-theme)
(load-theme 'tok t)

So most likely the issue is not in my theme. My theme is located at https://github.com/topikettunen/tok-theme and in there I also do:

;;;###autoload
(when (and (boundp 'custom-theme-load-path) load-file-name)
  (add-to-list 'custom-theme-load-path
               (file-name-as-directory (file-name-directory load-file-name))))

which should add the theme to your custom-theme-load-path (and it does when I require the theme and load it without use-package.

My theme is also at MELPA so when I load it without :load-path, e.g.:

(use-package tok-theme
  :defer nil
  :if window-system
  :init
  (load-theme 'tok t))

it works fine.

Am I doing something terribly wrong here?

Thanks in advance!

topikettunen avatar Nov 28 '21 23:11 topikettunen