oremacs
oremacs copied to clipboard
Question about organization of your files
Hi there, just a subjective question about organization:
It seems that the adoption of use-package often has people writing their configs in the style of:
(use-package foo
;; bindings for foo
;; hooks for foo)
(use-package bar
;; bindings for bar
;; hooks for bar)
Whereas you generally seem to prefer
;; init.el
(use-package foo)
(use-package bar)
;; keybindings.el
bindings for foo
bindings for bar
;; hooks.el
hooks for foo
hooks for bar
I was wondering why you favor this organization scheme? Does it offer performance advantages? Is it easier to wrap your head around? Does it scale better? I tried organizing it this way but found that it sometimes complicated things because I would, for example, have to use an eval-after-load
in keybindings.el
to avoid an error about a keymap that doesn't exist yet. Perhaps you just handle this with some autoloads?
After reading your post on profiling, it seems you do a lot of this to improve performance by manually adding autoloads. In a comment you also said that you don't put everything in use-package
blocks because it splits up the autoloads in a bunch of different places. I'm still a bit confused about the last part of your comment, though:
use-package :commands
is only viable when there aren't too many. It basically just splits what update-all-autoloads generates into various places. update-all-autoloads is automatic on one hand, but only for fixed directories. So I use both.
Mainly I just don't get the last part: if it's more performant to put all your autoloads in one place, why use the :commands
keyword? What does the comment about fixed directories mean exactly?
Fixed directories means (looking at the source of update-all-autoloads
):
-
emacs-d
/ -
emacs-d
/modes/ -
emacs-d
/git/org-fu/ -
emacs-d
/personal/
update-all-autoloads
allows to easily hook up all ;;;autoload
cookies in many modes/ora-*.el
files.
The advantage of e.g. keeping all Python config in modes/ora-python.el
are:
- one less level of nesting than with
use-package
- all config for one mode neatly in one file
- no need to think of further lazy-loading: once
python-mode-hook
is run,ora-python
and load all Python config, since it will likely be useful.