(add-to-list grep-find-ignored-directories "build")
(add-to-list grep-find-ignored-directories "dist")
(add-to-list grep-find-ignored-directories "lib")
It defined in grep.el as:
(defcustom grep-find-ignored-directories
vc-directory-exclusion-list ...)
If I dont put
(require 'grep)
before add-to-list I get
Symbol's value as variable is void: grep-find-ignored-directories
But adding a lot of 'require' slow down start up time.
To resolve this I can use:
(add-hook grep-setup-hook (lambda nil
(add-to-list grep-find-ignored-directories "build")
(add-to-list grep-find-ignored-directories "dist")
))
What usual pattern for common case?
Put 'require' or 'add-hook'.
With 'require' code look more linear but load time increased.
With 'add-hook' code become some messy.
Is there standard for setup-hook name?
Is there requirement put to *.el file such hook?
Who invoke setup-hook?
Is it called automatically?
Is there requirement invoke it only once?
Also 'grep-setup-hook' declared as ###autoload.
So if I wrote '(add-hook grep-setup-hook ...)' Emacs read grep.el,
so it is more simply use '(require 'grep)'?
If you want to use `add-to-list' on a variable that is not defined
until a certain package is loaded, you should put the call to `add-to-list'
into a hook function that will be run only after loading the package.
`eval-after-load' provides one way to do this. In some cases
other hooks, such as major mode hooks, can do the job.