jwiegley / use-package

A use-package declaration for simplifying your .emacs
https://jwiegley.github.io/use-package
GNU General Public License v3.0
4.4k stars 259 forks source link

Strange behavior during byte-compilation. #636

Open jaccarmac opened 6 years ago

jaccarmac commented 6 years ago

I've been playing with techniques to speed up Emacs, which led me down the road of byte-compiling my init file. As you can see, that file contains a bunch of quse-package expressions which macroexpand into use-package expressions which macroexpand into nice tight initialization code. The linked artifact is the version of the file I've used without byte compilation for some time. To eliminate warnings I took advantage of the new use-package 2 features and tried to predefine functions which the compiler complained about.

However, :functions and :defines seem to have no effect on the generated warnings. I looked for issues similar to mine and found #198, then dove into the source here: https://github.com/jwiegley/use-package/blob/6af4b6caf67f5fbd63429d27fa54a92933df966a/use-package-core.el#L633 and noticed the use of byte-compile-current-file. I'm not well-versed in Emacs' macro-expander, but are recursive expansions done in the same file or in such a way that the file would be different? eval-when-compile is implemented without checking state variables, with a mechanism which I'm not familiar with and need to look into further.

My issue can be solved by using :preface, defvar, and declare-function liberally but the other keywords are a nice convenience feature and perhaps solving the recursive expansion problem can help with that other reported bugs.

I develop a package that I found useful to leverage use-package's power in my own config. You can find it at jaccarmac/quse-package and example usage in http://chiselapp.com/user/jaccarmac/repository/dot-emacs-dot-d/artifact/90fda1f9e5dbe46c. May be helpful for resolving the issue, maybe not.

Emiluren commented 6 years ago

I also had this problem. The discussion in #590 put me on the right track.

I solved it by adding this

(eval-when-compile
  (setq use-package-expand-minimally byte-compile-current-file))
jaccarmac commented 6 years ago

Wasn't aware of that option, thanks much!

skangas commented 1 year ago

Could someone explain what is the problem here exactly, or even better provide a minimal example that is not working? As it stands, I don't think I understand what this is about. I also don't personally byte-compile my init file, so please forgive me if I'm missing something obvious.

Thanks in advance.