For ***years*** I've been looking for a solution to this problem,
and I'm truly amazed that I have yet to find it: how to get a
fast-starting version of emacs. The problem is that I have a big
.emacs file and a big Emacs desktop, which means that my Emacs takes
forever to start. This is fine most of the time, but occasionally
I want a fast-starting emacs session (e.g. when I run "sudo emacs"
to edit a superuser-owned config file), and it's infuriating to
wait for emacs to go through a lengthy and useless song-and-dance...
I just can't believe there is no way around this. (Other than, of
course, using vi.)
Note that using the emacsclient is no solution, because this requires
that a version of Emacs be already running, which often defeats
the purpose (not only do I have to wait another eternity for this
new Emacs session to start, but then I have to start the server in
the new session).
Any words of wisdom would be much appreciated!
TIA!
Kynn
--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
> For ***years*** I've been looking for a solution to this problem,
> and I'm truly amazed that I have yet to find it: how to get a
> fast-starting version of emacs. The problem is that I have a big
> .emacs file and a big Emacs desktop, which means that my Emacs takes
> forever to start. This is fine most of the time, but occasionally
> I want a fast-starting emacs session (e.g. when I run "sudo emacs"
> to edit a superuser-owned config file), and it's infuriating to
> wait for emacs to go through a lengthy and useless song-and-dance...
>
> I just can't believe there is no way around this. (Other than, of
> course, using vi.)
>
> Note that using the emacsclient is no solution, because this requires
> that a version of Emacs be already running, which often defeats
> the purpose (not only do I have to wait another eternity for this
> new Emacs session to start, but then I have to start the server in
> the new session).
>
> Any words of wisdom would be much appreciated!
Emacs has tons of functionality baked in right from the start, yet its
startup time is reasonably fast if you don't have customizations. So,
learning from core emacs means learning how to start up fast. There
are lots of possible improvements you can make:
- don't use `require', use autoloads:
http://www.emacswiki.org/emacs/AutoLoad
Magic comments can help, see (info "(elisp) Autoload")
Use `update-autoloads-from-directories' to automatically generate
the autoloads for you.
- for stuff that can only be configured once a library is loaded, use
`eval-after-load'.
- make a new emacs image with all your favourite libraries already
loaded: http://www.emacswiki.org/emacs/DumpingEmacs
- start emacs as part of system startup with the --daemon switch:
http://www.emacswiki.org/emacs/EmacsAsDaemon
- byte-compile the libraries you use; consider byte-compiling your
.emacs if it is huge
- remove extensions you don't use
- measure the progress you make: use the lisp function benchmark-run,
or `time' on the command line. Try adding (kill-emacs) at the end
of your .emacs file to get meaningful results for this.
My init file has 1677 lines, emacs starts in 2.3 seconds (hot
cache). Hmmm... this could be improved. 8-)
Happy tuning!
Anselm
--
Anselm Helbig
mailto:anselm.helb...@googlemail.com
I frequently use Zile in that context. Bare-bones editor with Emacs
keybindings. Great for the odd config file edit from a terminal.
- Michael
--
mouse, n: A device for pointing at the xterm in which you want to type.
emacs -Q
> - don't use `require', use autoloads:
> http://www.emacswiki.org/emacs/AutoLoad
> - for stuff that can only be configured once a library is loaded, use
> `eval-after-load'.
> - make a new emacs image with all your favourite libraries already
> loaded: http://www.emacswiki.org/emacs/DumpingEmacs
> - start emacs as part of system startup with the --daemon switch:
> http://www.emacswiki.org/emacs/EmacsAsDaemon
> - byte-compile the libraries you use; consider byte-compiling your
> .emacs if it is huge
> - remove extensions you don't use
> - measure the progress you make: use the lisp function benchmark-run,
> or `time' on the command line. Try adding (kill-emacs) at the end
> of your .emacs file to get meaningful results for this.
All good points :)
I use all of (1) autoloading, (2) --daemon mode for most of my quick
editing sessions, (3) I keep trimming my configuration from stuff I have
not used for months, and (4) fire up 1-2 different instances besides the
background daemon process: one for Gnus-only stuff, and maybe another
one for IRC windows.
Another neat thing to do is install a light-weight clone like `mg' and
use that for very basic editing. I even went so far as to import mg in
my own copy of the FreeBSD src/ tree and attach it to the normal build
process, so my laptop's custom FreeBSD version now includes:
$ which mg
/usr/bin/mg
This way even when my full Emacs installation is not available (i.e. in
single user mode) I can use a lean and fast editor with very familiar
key bindings.
There are packages for `mg' and other mini clones of Emacs in the
package collection of most UNIX-like systems today, so installing one of
them is another thing that may be useful to consider.
>On May 18, 5:05=A0am, kj <so...@987jk.com.invalid> wrote:
>> =A0The problem is that I have a big
>> .emacs file and a big Emacs desktop, which means that my Emacs takes
>> forever to start. =A0This is fine most of the time, but occasionally
>> I want a fast-starting emacs session (e.g. when I run "sudo emacs"
>> to edit a superuser-owned config file), and it's infuriating to
>> wait for emacs to go through a lengthy and useless song-and-dance...
>emacs -Q
I've gotten some very useful ideas in this thread (thanks Anselm,
Michael, and Giorgios), but this one actually blew me away. In
all my years using emacs (decades really) I never knew of this
command-line switch. In fact, after rummaging through the man page
and the emacs docs, I was not able to find it. But it works like
gangbusters. Thanks!
kynn
Just like the spaghetti sauce "it's in theya":
C-h r m intial options
Well, maybe you'd need to take another look at emacs --daemon ;-) I have
run it when my (X) *session* starts (no need for tricks to put it in
system startup scripts). Emacs starts within a cpl of seconds (1000 line
.emacs).
Then for the rest of the day I use emacsclient -c; lightning fast.
With emacs --daemon all the trimming, autoloading etc becomes much less
important.
Best wishes,
Dirk.
--
Dirk-Jan C. Binnema Helsinki, Finland
e:dj...@djcbsoftware.nl w:www.djcbsoftware.nl
pgp: D09C E664 897D 7D39 5047 A178 E96A C7A1 017D DA3C
>> > Note that using the emacsclient is no solution, because this requires
>> > that a version of Emacs be already running, which often defeats
>> > the purpose (not only do I have to wait another eternity for this
>> > new Emacs session to start, but then I have to start the server in
>> > the new session).
>
> Well, maybe you'd need to take another look at emacs --daemon ;-) I have
> run it when my (X) *session* starts (no need for tricks to put it in
> system startup scripts). Emacs starts within a cpl of seconds (1000 line
> .emacs).
>
> Then for the rest of the day I use emacsclient -c; lightning fast.
>
> With emacs --daemon all the trimming, autoloading etc becomes much less
> important.
>
> Best wishes,
> Dirk.
Emacs daemon mode is great, but only available with emacs 23.
However, another point I wanted to mention. There is no need to do sudo
emacs to edit a file as root. You can do this from within your normal
running emacs using tramp. 'su' will work too.
Tim
--
tcross (at) rapttech dot com dot au
| > > Note that using the emacsclient is no solution, because this requires
| > > that a version of Emacs be already running, which often defeats
| > > the purpose (not only do I have to wait another eternity for this
| > > new Emacs session to start, but then I have to start the server in
| > > the new session).
>
| Well, maybe you'd need to take another look at emacs --daemon ;-) I have
| run it when my (X) *session* starts (no need for tricks to put it in
| system startup scripts). Emacs starts within a cpl of seconds (1000 line
| .emacs).
>
| Then for the rest of the day I use emacsclient -c; lightning fast.
>
| With emacs --daemon all the trimming, autoloading etc becomes much less
| important.
Hi,
I just tried that Dirk, it seems emacsclient doesn't read my .Xresources
files then; is this expected?
tia,
--
Jean
this one is pretty good cure for a fat desktop file
,----[ C-h v desktop-restore-eager ]
| desktop-restore-eager is a variable defined in `desktop.el'.
| Its value is 5
|
| Documentation:
| Number of buffers to restore immediately.
| Remaining buffers are restored lazily (when Emacs is idle).
| If value is t, all buffers are restored immediately.
|
| You can customize this variable.
|
| This variable was introduced, or its default value was changed, in
| version 22.1 of Emacs.
`----
It should speed things up quite a bit to byte compile a major part of
your ~/.emacs as another file which is then loaded on start-up.
In releases of Emacs prior to 22, you can use `emacs -q --no-site-file'. It does
the same thing as does `emacs -Q' in Emacs 22 and later.
| > > Note that using the emacsclient is no solution, because this requires
| > > that a version of Emacs be already running, which often defeats
| > > the purpose (not only do I have to wait another eternity for this
| > > new Emacs session to start, but then I have to start the server in
| > > the new session).
>
| Well, maybe you'd need to take another look at emacs --daemon ;-) I have
| run it when my (X) *session* starts (no need for tricks to put it in
| system startup scripts). Emacs starts within a cpl of seconds (1000 line
| .emacs).
>
| Then for the rest of the day I use emacsclient -c; lightning fast.
>
| With emacs --daemon all the trimming, autoloading etc becomes much less
| important.
Hi all,
emacs --daemon is really great!
However I wonder what's the best place to write the command; I'm running a
linux box with xorg started by "startx".
A first try was to write "emacs --daemon" in ~/.xsession, but then if I
leave my x session and enter another one, it aks a new emacs start and
that causes trouble.
I have then written "emacs --daemon" in my ~/.zshenv, and it starts all
right, but then opening a zsh shell also make it attempt to start the
daemon again!
I probably miss something very straightforward!
Thanks for any help,
--
Jean
| However I wonder what's the best place to write the command; I'm running a
| linux box with xorg started by "startx".
| A first try was to write "emacs --daemon" in ~/.xsession, but then if I
| leave my x session and enter another one, it aks a new emacs start and
| that causes trouble.
| I have then written "emacs --daemon" in my ~/.zshenv, and it starts all
| right, but then opening a zsh shell also make it attempt to start the
| daemon again!
Well I ended writing a zsh script (lauched in .xsession) to check if an
emacs server is running, and lauching the server only if there isn't any.
bye,
--
Jean
If you use gentoo,
you will find a gentoo package called emacs-daemon.
It start emacs --daemon as a service.
Even if you don't use gentoo, it should be easy to make it working in
another linux.
--
A + Thierry Volpiatto
Location: Saint-Cyr-Sur-Mer - France
| If you use gentoo,
| you will find a gentoo package called emacs-daemon.
| It start emacs --daemon as a service.
| Even if you don't use gentoo, it should be easy to make it working in
| another linux.
No, I am not (anymore) a gentoo user.
When using a system-wide emacs daemon, I imagine that all user
customizations are only loaded with emacsclient, while if started as a
user emacs daemon loads the config.
So I still wonder what is the best way (I'm the only user).
Cheers,
--
Jean (near Aix-en-Provence :-) )
I just launch emacs interactively once, and then on use emacsclient
(or just open from one of the emacs frames).
Of notable interest, when I change of workstation but still want to go
on working in the same emacs session, is:
laptop$ xhost +maincomputer
laptop$ ssh -X myself@maincomputer
maincomputer$ emacsclient --eval "(make-frame-on-display \"$DISPLAY\")"
which will open a frame on the X server in laptop from the emacs
running on maincomputer.
Since I don't log-out every day, I get usually emacs uptimes as long
as the computer uptimes (ie _months_). It wouldn't matter if my
.emacs needed five minutes to load...
--
__Pascal Bourguignon__
hm... this can be done with tramp mode, right?
greets,
Christian
Jean Magnan de Bornier <je...@bornier.net> wrote :
Well I ended writing a zsh script (lauched in .xsession) to check if an
emacs server is running, and lauching the server only if there isn't any.
bye,
--
Jean
For that purpose you may also instead patch emacsclient. I have done
that in EmacsW32. Those patches are written to work on all platforms
(but I have no idea if they do at the moment).
> thierry....@gmail.com wrote :
>
> | If you use gentoo,
> | you will find a gentoo package called emacs-daemon.
> | It start emacs --daemon as a service.
> | Even if you don't use gentoo, it should be easy to make it working in
> | another linux.
>
> No, I am not (anymore) a gentoo user.
> When using a system-wide emacs daemon, I imagine that all user
> customizations are only loaded with emacsclient, while if started as a
> user emacs daemon loads the config.
No you use a symlink for each user and each user will have his own init
file (.emacs) loaded.
The daemon in /etc/init.d is called emacs but the one i start is a
symlink of emacs called emacs.thierry that use the .emacs of user
thierry.
> So I still wonder what is the best way (I'm the only user).
>
> Cheers,
--
> For ***years*** I've been looking for a solution to this problem,
> and I'm truly amazed that I have yet to find it: how to get a
> fast-starting version of emacs. The problem is that I have a big
> .emacs file and a big Emacs desktop, which means that my Emacs takes
> forever to start. This is fine most of the time, but occasionally
> I want a fast-starting emacs session (e.g. when I run "sudo emacs"
> to edit a superuser-owned config file),
C-x C-f /sudo::/etc/fstab RET
--
David Kastrup
I use this which is great. Open the file in normal mode, and then C-x
C-r to switch to root privs.
,----
| (defun find-alternative-file-with-sudo ()
| "Open current buffer as root!"
| (interactive)
| (when buffer-file-name
| (find-alternate-file
| (concat "/sudo:root@localhost:"
| buffer-file-name))))
|
| (global-set-key (kbd "C-x C-r") 'find-alternative-file-with-sudo)
`----
Nice one. Only the first time I use it, it take some time. When I do it
a second time, it is quit fast.
> David Kastrup <d...@gnu.org> writes:
>> C-x C-f /sudo::/etc/fstab RET
>
> Nice one. Only the first time I use it, it take some time. When I do
> it a second time, it is quit fast.
With Emacs 22 it's slow first time. Fortunately with Emacs 23 /sudo: and
/su: are always fast.
That explains it. The system I tried it on was still running 22.3.1. I
tried it on another system with 23 and there was no delay.