[Top][All Lists]

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

Re: Emacs Package Loading & .emacs ??

From: David Masterson
Subject: Re: Emacs Package Loading & .emacs ??
Date: Mon, 31 Mar 2014 16:43:06 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (cygwin)

W. Greenhouse <address@hidden> writes:

> David Masterson <address@hidden> 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.

Something is not right here.  I have done a package install on Org
(8.2.5h), but, if I blank out my .emacs, then org-version is set to

>> 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.

As mentioned above, if I don't (require 'org) at the right time, then
the wrong version of org is loaded.  Since org-version is already
defined, then that means that Org has already been loaded and, so, there
is no need to reload it.  The only problem is that it is that wrong one.

> 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.

Hmmm.  I'll have to recheck that.  This goes against the standard way of
loading Emacs libraries that I've been using for 20+ years! Never needed
to use after-init-hook before. It's so hard to teach an old dog new

David Masterson

reply via email to

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