From: W. Greenhouse <wgreenhouse-sGOZH3hwPm2sTnJN9+BGXg@public.gmane.org>
To: help-gnu-emacs-mXXj517/zsQ@public.gmane.org
Subject: Re: Emacs Package Loading & .emacs ??
Date: Mon, 31 Mar 2014 17:18:52 +0000 [thread overview]
Message-ID: <87ha6e9thf.fsf@motoko.kusanagi> (raw)
In-Reply-To: 86bnwnkm5d.fsf@gmail.com
David Masterson <dsmasterson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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
next prev parent reply other threads:[~2014-03-31 17:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-31 4:49 Emacs Package Loading & .emacs ?? David Masterson
2014-03-31 7:43 ` Martin
2014-03-31 17:18 ` W. Greenhouse [this message]
2014-04-01 11:49 ` Alan Schmitt
2014-04-01 14:44 ` W. Greenhouse
[not found] ` <mailman.18607.1396286371.10748.help-gnu-emacs@gnu.org>
2014-03-31 23:43 ` David Masterson
2014-03-31 23:51 ` David Masterson
2014-04-01 1:38 ` Rusi
2014-04-01 14:42 ` W. Greenhouse
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ha6e9thf.fsf@motoko.kusanagi \
--to=wgreenhouse-sgozh3hwpm2stnjn9+bgxg@public.gmane.org \
--cc=help-gnu-emacs-mXXj517/zsQ@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).