unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Optimizing startup speed
@ 2011-11-03 16:46 Buchs, Kevin
  2011-11-03 20:57 ` Peter Dyballa
  0 siblings, 1 reply; 4+ messages in thread
From: Buchs, Kevin @ 2011-11-03 16:46 UTC (permalink / raw)
  To: help-gnu-emacs, philipp.haselwarter

Philipp,

You mentioned, in reply to the thread "emacs -- simple"

> Proper use of autoload, eval-after-load and some factorization of your startup files into package specific configuration, plus byte compiling should reduce startup time significantly.

I wonder if you could amplify what you mean by "factorization of your startup files into package-specific configuration". It seems obvious, but I'm not sure I see the benefit, so would you explain why this helps startup speed.


Kevin Buchs   |  Senior Engineer  |  Department of Physiology and Biomedical Engineering - SPPDG
507-538-5459  |   buchs.kevin@mayo.edu  |  http://www.mayo.edu/sppdg
Mayo Clinic  |  200 1st St. SW  |  Rochester, MN 55905  



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Optimizing startup speed
  2011-11-03 16:46 Optimizing startup speed Buchs, Kevin
@ 2011-11-03 20:57 ` Peter Dyballa
  2011-11-04  0:04   ` Philipp Haselwarter
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Dyballa @ 2011-11-03 20:57 UTC (permalink / raw)
  To: Buchs, Kevin; +Cc: help-gnu-emacs, philipp.haselwarter


Am 03.11.2011 um 17:46 schrieb Buchs, Kevin:

> I wonder if you could amplify what you mean by "factorization of your startup files into package-specific configuration".

I think Philipp was advocating the use of the require statement, which does not load the ELisp file at once. Another option is to load the required Elisp file with a hook that customises this ELisp software when the file was completely read in.

--
Greetings

  Pete

Wer nichts zu verbergen hat, hat schon alles verloren.
				(Juli Zeh)




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Optimizing startup speed
  2011-11-03 20:57 ` Peter Dyballa
@ 2011-11-04  0:04   ` Philipp Haselwarter
  2011-11-07  0:28     ` Peter Dyballa
  0 siblings, 1 reply; 4+ messages in thread
From: Philipp Haselwarter @ 2011-11-04  0:04 UTC (permalink / raw)
  To: help-gnu-emacs

Actually `require' /does/ load the whole file as soon as
(require 'library) is evaluated. Many packages for emacs suggest to just
`require' them in your .emacs, but this is not a very good idea, as it
loads on startup (pulling in dependencies etc).
For example if you just want to read your mail with gnus, you don't need
to lose your time loading libraries for dealing with java code.

Most packages have some kind of entry point (except ofc things like
global minor modes that you really always want to be active).
Ideally the package comes with a 'package-loads.el' or '-autoloads.el'
which does not contain the actual library code but just the signatures
of these entry points and the name of the file where the actual
definition resides.
Emacs then offers you to use these functions, often as hooks or
commands, and loads the actual code just when it needs (ie when you
first call it).
If the package fails to provide autoloads you can easily define them
yourself. For example if the package « brew.el » contains a command
« brew­arabica », you could put the line
--8<---------------cut here---------------start------------->8---
(autoload 'brew­arabica "brew" "Brews a nice cup of arabica" t)
--8<---------------cut here---------------end--------------->8---
in your config file. Now startup won't be slowed down and the brew
package will be loaded just when you need it.

Factoring out configuration of features/packages also has the advantage
of reducing the quantity of code that has to be evaluated.
For example, if our "brew" package contained a « after­brew­hook »,
there's no point in assigning values to that hook until the package is
loaded. This can be achieved using `eval-after-load':
--8<---------------cut here---------------start------------->8---
(eval-after-load 'brew '(add-hook 'after­brew­hook 'brew­add­sugar))
--8<---------------cut here---------------end--------------->8---

For big packages you can easily wind up with a few hundred lines of
configuration. In those cases you factor it out to a my-brew-config.el
file that you require after « brew » is loaded:

this goes into .emacs:
--8<---------------cut here---------------start------------->8---
(eval-after-load 'brew '(require 'my­brew­config))
--8<---------------cut here---------------end--------------->8---

and this into my-brew-config:
--8<---------------cut here---------------start------------->8---
(add­hook 'after­brew­hook 'brew­add­sugar)
(setq brew­sugar­per­cup 7)
--8<---------------cut here---------------end--------------->8---

Another advantage of organizing your stuff this way is that you can more
easily share (and debug) your configuration by keeping all your personal
data in one separate file (user-full-name, erc-nick, etc).

Once you have all this set up and find starting emacs still too slow you
can use 'C-u M-x byte-recompile-directory' or 'M-x byte-compile-file'
(`B' in dired) to compile additional packages and config files. Just be
careful to recompile after you change something in your config, emacs
will rather load my-brew-config.elc than my-brew-config.el.

I hope this makes things a little clearer :)

-- 
Philipp Haselwarter




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Optimizing startup speed
  2011-11-04  0:04   ` Philipp Haselwarter
@ 2011-11-07  0:28     ` Peter Dyballa
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Dyballa @ 2011-11-07  0:28 UTC (permalink / raw)
  To: Philipp Haselwarter; +Cc: help-gnu-emacs


Am 04.11.2011 um 01:04 schrieb Philipp Haselwarter:

> I hope this makes things a little clearer :)

Sure! One special case cannot be handled by this: that of using session.el and/or desktop.el. Restoring all the files can take some time, particularly then when you had some archives open when you quit GNU Emacs…

--
Mit friedvollen Grüßen

  Pete

If you're not confused, you're not paying attention.




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-11-07  0:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-03 16:46 Optimizing startup speed Buchs, Kevin
2011-11-03 20:57 ` Peter Dyballa
2011-11-04  0:04   ` Philipp Haselwarter
2011-11-07  0:28     ` Peter Dyballa

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