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

defvar, defun, defadvice, define-minor-mode #929

Closed grolongo closed 1 year ago

grolongo commented 3 years ago

Hi, for a long time I put all my (defun... under the :preface macro. Never had an issue so far.

Now I found there are :functions and :defines macros.

Should I set everything like this?:

all (defvar... under :defines all (defun... under :functions

But what about defadvice and define-minor-mode? Those works if I add them either in :preface or :config, but I'm looking for the use-package conventional way.

skangas commented 1 year ago

Hi, for a long time I put all my (defun... under the :preface macro. Never had an issue so far.

Great!

Now I found there are :functions and :defines macros.

Should I set everything like this?:

all (defvar... under :defines all (defun... under :functions

No, I think you should leave them under the :preface macro. Use :defines and :functions only if you need to silence byte-compiler warnings.

But what about defadvice and define-minor-mode? Those works if I add them either in :preface or :config, but I'm looking for the use-package conventional way.

The difference is that :preface is evaluated immediately, and :config is evaluated after the package has been loaded. Use whichever works for you. You can test this with the M-x pp-macroexpand-last-sexp command.

I hope that answers your questions, so I'm closing this issue.