From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sebastian Tennant Newsgroups: gmane.emacs.help Subject: Re: An alternative to a monolithic ~/.emacs init file Date: Fri, 09 Nov 2007 16:18:17 +0200 Message-ID: <873avf8pue.fsf@moley.moleskin.org> References: <1194455637.485972.177570@s15g2000prm.googlegroups.com> <1194544126.425679.261670@e9g2000prf.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1194617967 29018 80.91.229.12 (9 Nov 2007 14:19:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 9 Nov 2007 14:19: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 Nov 09 15:19:19 2007 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.50) id 1IqUhR-00042V-Nh for geh-help-gnu-emacs@m.gmane.org; Fri, 09 Nov 2007 15:19:09 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IqUhG-0002Km-6o for geh-help-gnu-emacs@m.gmane.org; Fri, 09 Nov 2007 09:18:58 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IqUgv-0002EB-7D for help-gnu-emacs@gnu.org; Fri, 09 Nov 2007 09:18:37 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IqUgu-0002Ck-Lf for help-gnu-emacs@gnu.org; Fri, 09 Nov 2007 09:18:36 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IqUgu-0002C9-7L for help-gnu-emacs@gnu.org; Fri, 09 Nov 2007 09:18:36 -0500 Original-Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IqUgt-0005aJ-K5 for help-gnu-emacs@gnu.org; Fri, 09 Nov 2007 09:18:36 -0500 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1IqUgm-0005Pq-9W for help-gnu-emacs@gnu.org; Fri, 09 Nov 2007 14:18:28 +0000 Original-Received: from 85.105.17.65 ([85.105.17.65]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 09 Nov 2007 14:18:28 +0000 Original-Received: from sebyte by 85.105.17.65 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 09 Nov 2007 14:18:28 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 63 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 85.105.17.65 User-Agent: Gnus/5.110007 (No Gnus v0.7) Emacs/22.1 (gnu/linux) Cancel-Lock: sha1:TsjSQN0YkjN9Zz2SPfATpIdzHdY= X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) 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 Xref: news.gmane.org gmane.emacs.help:49098 Archived-At: Quoth rustom : > Thanks. I think I understand autoload. Also I dont want needless > loading at emacs-startup -- its unlikely that in a given session I > will do C and python and ruby and org and tramp and elisp and ..... > though I do use all these once in a while. What I dont understand are > magic cookies and how emacs uses them; or more correctly *When* emacs > uses them. The elisp manual says: > > "These comments do nothing on their own, but they serve as a guide for > the command `update-file-autoloads', which constructs calls to > 'autoload' and arranges to execute them when Emacs is built." > Does this mean I have to rebuild emacs if I want to use this ?! First of all, autoloads exist precisely for the reason you've stated; avoiding needless loading of functions at startup. Consider the function 'foo' defined in bar.el. If your ~/.emacs includes the line (autoload 'foo "bar.el" "My function foo" t) then Emacs knows where to find the function definition, if and when you type the command 'M-x foo'. The function itself is not loaded until you call it, (the autoload call means Emacs is simply aware of the name of the function, and the file where it is found), thus saving memory resources and reducing startup time. A better name than 'autoload' might be: 'load-later' or, 'dont-load-until-needed-but-heres-where-to-find-it-anyway' I agree the explanation in the manual is unclear/inadequate. You certainly don't have to rebuild Emacs! update-file-autoloads is called when emacs is rebuilt, yes, but there's nothing to stop you calling update-file-autoloads yourself. It works by parsing a file and constructing autoload calls (like the one above) based on occurrences of magic cookies (;;;###autoload) in elisp code. The constructed autoload calls are then written to a file named according to the value of the variable generated-autoload-file. update-directory-autoloads works in exactly the same way, but on all the files within a directory. So, (let ((generated-autoload-file "~/elisp/dotemacs/auto-autoloads.el")) (update-directory-autoloads "~/elisp/lib/")) works by temporarily binding the value of generated-autoload-file so that autoload calls based on magic cookies found within files in ~/elisp/lib are written to a file within ~/elisp/dotemacs. As for loaddefs.el, this is the equivalent of auto-autoloads.el above. It is a file full of autoload calls created by the update-file-autoloads function. There are no less than six loaddefs.el on my machine but the main one (/usr/share/emacs/22.1/lisp/loaddefs.el) is some 33,000 lines long and I have no doubt it was generated once at build time, but is loaded every time at startup, making all those functions available to me, but not actually loading any of them until they're needed. Perhaps someone else could confirm that this is the case. Sebastian