abo-abo / oremacs

My Emacs config
https://oremacs.com/
296 stars 33 forks source link

Question about organization of your files #32

Open gcantieni opened 4 years ago

gcantieni commented 4 years ago

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?

gcantieni commented 4 years ago

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?

abo-abo commented 4 years ago

Fixed directories means (looking at the source of update-all-autoloads):

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: