help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Elisp question: when 'require' needed?


From: Oleksandr Gavenko
Subject: Elisp question: when 'require' needed?
Date: Fri, 14 Jan 2011 11:41:54 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7

I wont update in .emacs 'grep-find-ignored-directories':

(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)'?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]