3

I used to run Emacs on Linux using Emacsclient, it is really easy and great experience:

emacs --daemon
emacsclient

When I work on a Windows machine, Emacs starts very slow. It seems there's no default support for emacsclient. So I decide to use the use-package package to reduce Emacs startup time. Since there're several packages, I'd like to know which cost the most startup time, and load it with use-package.

If I am not in the right direction, please correct me.

3
  • Which Windows package are you using? In the one I'm using there's a emacsclient.exe.
    – legends2k
    Commented Jan 6, 2015 at 10:06
  • @legends2k I'm using emacs form Chocolatey, a apt-get like package management tool for Windows. I use it to install many opensource or free software. There's a emacsclient.exe too. How do you use it? Emacs doesn't support daemon on Windows.
    – Nick
    Commented Jan 6, 2015 at 10:39
  • Related questions have already been discussed at length: What can I do to speed up my start-up?, How can I troubleshoot a very slow Emacs?.
    – Dan
    Commented Jan 6, 2015 at 13:40

2 Answers 2

6

Since you said you are already using use-package, you can turn on its own verbose option that reports how long each package takes to load.

Use customize-option use-package-verbose or put this in your init file:

(setq use-package-verbose t)

Then restart Emacs and check your *Messages* buffer. The output will look something like:

Loading package dash...done (0.015s)
Loading package ido...done (0.109s)
Loading package company...done (0.125s)
Loading package elisp-slime-nav...done (0.047s)
Loading package smart-mode-line...done (0.046s)

By default times are reported that are longer than 0.01 seconds. You can change this threshold too, see use-package-minimum-reported-time.

1

This is based on Emacs 24.4.1 (KAEL) on Windows 7 from the emacs-w64 project, but should work on other releases of the same major version. Add this to your .emacs:

(load "server")
(unless (server-running-p) (server-start))

which will run the server if it's not running; taken from here. If you're using cygwin/msys/msys2 then you could add this to your .bashrc:

edit_file() {
        emacsclient -nqa "runemacs.exe" $1 &
}

alias edit=edit_file

or do the equivalent in a batch script for cmd. Now all you've to do is

edit 1.txt   # will start the server, if it's not running
edit 2.txt   # will send a request to the server to open this file

The explanation part is that emacsclient would run runemacs.exe if a server is not running; -q would be to silence it's success message. -n is to not wait for server to return; if not for -n, you should clean up the buffer using server-edit and not the usual kill-buffer.

One additional point is that, if you want to use emacsclient.exe from GUI instead of CLI/TUI then use emacsclientw.exe.

7
  • Error: file name or argument required. (I downloaded Emacs-w64 from your list, the same error occured.) (Thank you.)
    – Nick
    Commented Jan 6, 2015 at 12:10
  • What shell did you try it on, bash or cmd? Also what command gave you that error?
    – legends2k
    Commented Jan 6, 2015 at 13:21
  • I run it with the native Windows PowerShell, and bash, both failed with the same error: file name or argument required.
    – Nick
    Commented Jan 6, 2015 at 13:23
  • Try this emacsclient -nqa "runemacs.exe" <some_file> & on bash, is it working?
    – legends2k
    Commented Jan 6, 2015 at 13:25
  • This post does not answer OP's stated question about startup time. If the OP can post a separate question on emacsclient for Windows, this answer would make more sense there.
    – Dan
    Commented Jan 6, 2015 at 13:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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