From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Oleksandr Gavenko Newsgroups: gmane.emacs.help Subject: Elisp question: when 'require' needed? Date: Fri, 14 Jan 2011 11:41:54 +0200 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1294998267 22393 80.91.229.12 (14 Jan 2011 09:44:27 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 14 Jan 2011 09:44:27 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jan 14 10:44:23 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PdgCe-0005Zg-4x for geh-help-gnu-emacs@m.gmane.org; Fri, 14 Jan 2011 10:44:16 +0100 Original-Received: from localhost ([127.0.0.1]:44886 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PdgCd-0001MQ-44 for geh-help-gnu-emacs@m.gmane.org; Fri, 14 Jan 2011 04:44:15 -0500 Original-Received: from [140.186.70.92] (port=50655 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PdgAT-0000nk-37 for help-gnu-emacs@gnu.org; Fri, 14 Jan 2011 04:42:02 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PdgAR-0006Kw-Qh for help-gnu-emacs@gnu.org; Fri, 14 Jan 2011 04:42:00 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]:52704) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PdgAR-0006Kh-L0 for help-gnu-emacs@gnu.org; Fri, 14 Jan 2011 04:41:59 -0500 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1PdgAP-0004Jm-86 for help-gnu-emacs@gnu.org; Fri, 14 Jan 2011 10:41:57 +0100 Original-Received: from 91.193.68.214 ([91.193.68.214]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 14 Jan 2011 10:41:57 +0100 Original-Received: from gavenko by 91.193.68.214 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 14 Jan 2011 10:41:57 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 47 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 91.193.68.214 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org X-Spam-Report: 5.4 points; * -0.0 SPF_PASS SPF: sender matches SPF record * 4.0 RCVD_NUMERIC_HELO Received: contains an IP address used for HELO * -2.6 BAYES_00 BODY: Bayesian spam probability is 0 to 1% * [score: 0.0000] * 4.0 RCVD_IN_SBL RBL: Received via a relay in Spamhaus SBL * [91.193.68.214 listed in zen.spamhaus.org] Xref: news.gmane.org gmane.emacs.help:78445 Archived-At: 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)'?