From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: W. Greenhouse Newsgroups: gmane.emacs.help Subject: Re: Emacs Package Loading & .emacs ?? Date: Mon, 31 Mar 2014 17:18:52 +0000 Message-ID: <87ha6e9thf.fsf@motoko.kusanagi> References: <86bnwnkm5d.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1396286391 15495 80.91.229.3 (31 Mar 2014 17:19:51 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 31 Mar 2014 17:19:51 +0000 (UTC) To: help-gnu-emacs-mXXj517/zsQ@public.gmane.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org-mXXj517/zsQ@public.gmane.org Mon Mar 31 19:19:46 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WUfs7-000827-E2 for geh-help-gnu-emacs@m.gmane.org; Mon, 31 Mar 2014 19:19:43 +0200 Original-Received: from localhost ([::1]:50384 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WUfs6-0000LF-PL for geh-help-gnu-emacs@m.gmane.org; Mon, 31 Mar 2014 13:19:42 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52902) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WUfrn-0000Ko-PF for help-gnu-emacs-mXXj517/zsQ@public.gmane.org; Mon, 31 Mar 2014 13:19:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WUfrh-0004Sb-Ra for help-gnu-emacs-mXXj517/zsQ@public.gmane.org; Mon, 31 Mar 2014 13:19:23 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:59001) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WUfrh-0004SU-KT for help-gnu-emacs-mXXj517/zsQ@public.gmane.org; Mon, 31 Mar 2014 13:19:17 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WUfrf-0005xx-Ch for help-gnu-emacs-mXXj517/zsQ@public.gmane.org; Mon, 31 Mar 2014 19:19:15 +0200 Original-Received: from lumumba.torservers.net ([77.247.181.163]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 31 Mar 2014 19:19:15 +0200 Original-Received: from wgreenhouse by lumumba.torservers.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 31 Mar 2014 19:19:15 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 68 Original-X-Complaints-To: usenet-dbVV3NMTNubNLxjTenLetw@public.gmane.org X-Gmane-NNTP-Posting-Host: lumumba.torservers.net X-Archive: encrypt User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:9nRhOJpK+xRE3OQpOO/YVtkWe9s= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs-mXXj517/zsQ@public.gmane.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org-mXXj517/zsQ@public.gmane.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org-mXXj517/zsQ@public.gmane.org Xref: news.gmane.org gmane.emacs.help:96884 Archived-At: David Masterson writes: [...] > Can someone explain the package loading process? In particular, I get > the sense that the new package is added to the load-path *after* my > .emacs is loaded. Exactly right. (info "(elisp) Startup Summary") details the whole init process. In particular, note: 12. It loads your init file (*note Init File::). This is not done if the options `-q', `-Q', or `--batch' were specified. If the `-u' option was specified, Emacs looks for the init file in that user's home directory instead. ... 15. If `package-enable-at-startup' is non-`nil', it calls the function `package-initialize' to activate any optional Emacs Lisp package that has been installed. *Note Packaging Basics::. Note that `package-initialize' doesn't actually "load" packages either. What it does is populate `load-path' with the locations of package libraries, and scan the packages for autoloads. The package normally doesn't get loaded at all until one of these autoloads is triggered. > If that is true, what is the proper way to make use of the new package > as adding (require 'org) to my .emacs will pick up the original Org > and not the installed package? Should I physically delete the original > Org module that came with Emacs? No, don't attempt to delete stuff that came with Emacs. 1. You probably don't need to use (require 'org) at all. The idea of packages is that autoloads will be set up so that when you call one of the main entry points of a package (e.g. `org-mode', `org-agenda', `org-capture', etc.), the package will load the correct version. Explicitly requiring or loading the library before the package is loaded will foul this up. You can set package-related variables and even add to hooks before they are defined by the library, so (require 'org) doesn't actually do much that is useful but take up time during init. Customize also does the right thing automatically, in that setting package settings through Customize won't accidentally load the built-in version of the package. 2. The correct form would be (require 'org-install) anyway, if you were manually loading org. 3. If you decide for some reason that you really do need to use (require 'org-install), you should do this from `after-init-hook' (which is run at step 17 of (info "(elisp) Startup Summary"), well after package init), OR you can explicitly (package-initialize) early in init and (setq package-enable-at-startup nil) to skip step 15. above. (info "(emacs) Package Installation") details some of the pros and cons of each approach. There's also https://github.com/jwiegley/use-package, a macro to simplify package-related config without doing explicit loads. You can change which functions will auto-load the package, and set variables and run functions in a "lazy" way such that nothing much will happen at init but these changes will be applied when the library is actually loaded for the first time. It's complicated, but I hope this helps. -- WGG