jwiegley / use-package

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

compile-defun support? #615

Open alphapapa opened 6 years ago

alphapapa commented 6 years ago

Hi,

Forgive me if this is covered elsewhere, but I couldn't find any reference to it in the docs or old issues.

Would it be possible to add compile-defun support to use-package? For example, if I have several top-level use-package forms in my init file, and I want to byte-compile all the functions defined in one form's :config, it would be nice to be able to do this with compile-defun. The alternatives are, IIUC:

a. Copy the individual functions to top-level in a buffer and compile them individually. b. Byte-compile and load the entire file. c. Move the use-package form into its own file and byte-compile and load it.

Thanks.

skangas commented 1 year ago

How do you imagine that this would work? Should there be a new command that also byte-compiles everything in, say, :config, :preface, etc. in the use-package declaration? Or should it just compile the defun at point, nested inside a use-package declaration?

In terms of implementation, could we perhaps get away with narrowing, and then call compile-defun directly?