Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

According to these posts:

one can somehow replace require and load statements in the .emacs file to speed up the emacs start. However I don't know how to do this in detail.

For example I have (among other things) in my .emacs file the following require and load statements:

(load "auctex.el" nil t t)
(require 'alarm)
(require 'linked)
(load "nxhtml/autostart.el")
(require 'autoinsert)
(require 'recentf)
(require 'color-theme)
(load "~/.emacsaddons/emacs-color-theme-solarized/color-theme-solarized")
...

For alarm and linked there are corresponding files in a directory called .emacsaddons, for nxhtml there is a directory, for the others there are no corresponding files in .emacsaddons. I didn't include all require or load statements from my .emacs file in the example above, just a few where I feel that the steps for replacing them with autoload will differ between them (for example because some have el files unter .emacsaddons and some doesn't, or because nxhtml is a subdir of .emacsaddons...).

How are the detailed steps to replace everything by autoload functionality for improving the performance?

share|improve this question
add comment

2 Answers

As a first step towards autoloading, I would suggest that you convert your explicit load commands with paths appended to the list of things that emacs should load, as in:

(add-to-list 'load-path (expand-file-name "~/.emacs.d/"))

With that at the top of your .emacs, you can call other things that depend on loading other files so that they will be found.

Specifically for postponing loading files, for each (require 'foo) that you have in your .emacs, you should replace that with something similar to:

(autoload 'name-of-foo-mode "code-for-foo.el" "Minor/Major mode for foo" t)

You may have to experiment (perhaps read) the code for the respective .el file to see what is the name that you need to put in place of 'name-of-foo-mode. The most common are 'foo or 'foo-mode, but there is inconsistency.

In my case, I have these declarations close to the bottom of my .emacs:

(autoload 'textmate-mode "textmate" "Minor mode for automatic bracket pairs" t)
(autoload 'post-mode "post" "Mode for editing e-mails" t)
(autoload 'turn-on-reftex "reftex" "Minor mode for references in TeX files" t)
(autoload 'mode-compile "mode-compile" "Compile current buffer" t)
(autoload 'markdown-mode "markdown-mode" "Major mode for Markdown files" t)

but some of the declarations that I to require before I moved to autoloading were:

(require 'reftex)
(require 'post)
(require 'compile)
(require 'textmate)

So, as I said, you may have to do some experimentation or code reading, but, in the end, it is worth it, as it will save you some time if you invoke emacs frequently.

share|improve this answer
add comment

The best way that I have found to get emacs started quickly is to daemonize the process. These instructions pertain to emacs23. Prior versions have server/client ability, but it can be more difficult to configure. When I first login to my desktop, I execute emacs --daemon. After this, every time that I need emacs I execute emacsclient -c filename and it pops up instantly. When using emacs in server/client mode, you need to break the habit of using C-x C-c to exit, instead typing C-x #. FWIW, this is something that emacs23 seems to fix, as I have on occasion caught myself typing C-x C-c without killing the server process, but I still hold on to my old habits.

Depending on your requirements, this may work out better than manipulating your configuration for little gain.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.