Function autoloads are handled elegantly by dh-elpa. After installing a
package, you can just put (turn-on-some-global-minor-mode) in your
~/.emacs, and everything works fine.
Themes defined with `deftheme' don't work so well. After installing a
theme, a simple call to `load-theme' in your ~/.emacs will fail.
Two possible workarounds are:
(package-initialize)
(load-theme 'zenburn t)
or
(add-hook 'after-init-hook (lambda () (load-theme 'zenburn)))
but this really shouldn't be necessary. In short, ELPA packages
supplying themes are currently second-class citizens in the elpa-*
namespace.
I'm filing this bug against dh-elpa for the time being, but there might
not be any sane patch to dh-elpa that will resolve the issue. The only
solution might be to implement autoloads for defthemes upstream.
If you are hitting this bug with your package, a sample README.Debian
giving a workaround for users is available in src:zenburn-emacs.
[2016-12-10 09:40] Sean Whitton <spwhitton@spwhitton.name>
Thank you for filing bug.
I see two actions we can perform to improve our situation.
1. Install README.Debian file by dh-elpa if we detect that package is
theme and no README.Debian is already provided. If README.Debian is
provided, we can grep it for 'package-initialize', to ensure that
it mentions this issue.
2. We can advice #'load-theme. Something like this:
~~~elisp
(defadvice load-theme
(before load-theme-before-enabling (theme no-confirm no-enable))
"Function autoloads are handled elegantly by dh-elpa. After installing a
package, you can just put (turn-on-some-global-minor-mode) in your
~/.emacs, and everything works fine.
Themes defined with `deftheme' don't work so well. After installing a
theme, a simple call to `load-theme' in your ~/.emacs will fail. This advice
'require's a feature, that correspond to theme to be loaded."
(ignore-errors
(require (intern (format "%s-theme" theme)))))
~~~
I know that advices are dangerous, but I believe that this one can
not have any implications, beside negligible perfomance ones.
Hello Dmitry, You CCed your message to <submit@bugs.debian.org> instead of <847690@bugs.debian.org>. I've resent it for you. Please check To,Cc carefully! As I said in another thread, I don't think we should implement code to merge a note into README.Debian when this is at best a temporary solution. Too many edge cases. Thank you very much for this code snippet. dh_elpa could add it to the emacsen-startup script for a theme package. I'll look into implementing this towards the end of this month.
[2016-12-13 11:23] Sean Whitton <spwhitton@spwhitton.name> Sorry. Will make some automatic check one day. Fine. I agree, that fixing limitation is better then documenting it. Ok.
Hello, Hmm, I'm not sure, but perhaps this problem is not actually about `deftheme' themes. I think perhaps no dh_elpa package autoloads happen until `package-initialize' is called. That would make this a 'wontfix'.