I am looking for method to use two different config files - init files. First config: when I am coding in full Emacs windows (open file as emacs namefile this define ~/.emacs_conf2) Second: when I would fast open file (without all packages, only some shortcuts etc) into terminal (commend- emacs namefile - nw this define ~/.emacs_conf2)?

Thanks for answer and explanation of your methods, regards!

  • I guess, you don't want to start Emacs using emacs -q -l ~/.emacs_config1 & emacs -q -l ~/.emacs_config2?
    – Nsukami _
    Jan 7, 2017 at 16:45
  • Thanks, I see your point of view, I would like have it automatic if I have emacs namefile -nw this define ~/.emacs_conf1 if I open emacs namefile this define ~/.emacs_conf2 Jan 7, 2017 at 16:57
  • 2
    In that case you can simply check if you're using GUI with (display-graphic-p) and then load the full config or a cut down version of it for the terminal.
    – user12563
    Jan 7, 2017 at 17:00
  • 3
    Are you fundamentally opposed to having certain packages loaded, or is speed the main concern? Put another way: there's a way to get emacs to load muchmuch faster for editing small files, say in the terminal (using emacsclient); do you know about that? Is two configs what you absolutely need, or just a fast and a slow way to load emacs?
    – Gastove
    Jan 7, 2017 at 17:01
  • @Gastove thank you, I am not sure that I understand. Main goal is to open emacs faster as you said. However I would have some of my config lines. Can you go on more details? Jan 7, 2017 at 17:08

3 Answers 3


As I can see from one of your comments, the main point is to run Emacs faster in some cases. Then there are several options for you.

  1. You can load your GUI-related configuration only when you run Emacs in GUI mode. You can use something like the following code (just place your GUI-related configuration in init_gui.el):

    (when window-system
      (load "~/.emacs.d/init_gui.el"))

NOTE: load function should get the full path to your init_gui.el, otherwise it will search for the file in your load-path. Of course, it is also possible to put the location of you init_gui.el to load-path with (add-to-list 'load-path "path_to_the_directory_with_your_file").

  1. You can autorun Emacs server and then just use emacsclient to connect to it. (As far as I know Emacs server will not work on Windows.) It will be quite fast even in GUI mode. In this case you need to put the following code to you configuration file:

    (require 'server)
    (unless (server-running-p)

Also, you can look at use-package, which can help you "to isolate package configuration in your .emacs file".

  • where should I keep the init_gui.el? I tried to storage it in next to ~/.emacs and in ~/.emacs.d/ . Both doesn't work, what do I do wrong? thanks for your help Jan 8, 2017 at 15:50
  • 1
    You probably want the file name in the load to specify the full name. e.g. ""~/init_gui.el" or "~/.emacs.d/int_gui.el", or whatever (I'd've called it "~/.emacs_gui.el" myself, or actually because of my more complex setup, it'd be "~/.../emacs/gui.elc")
    – MAP
    Jan 8, 2017 at 23:59
  • @MichalSzczep, I've just updated my answer. As @MAP put it load gets full path to the file. Jan 10, 2017 at 9:04
  • 1
    It would make sense to put it in ~/.emacs.d/ and use (load (locate-user-emacs-file "init_gui.el")) to load it.
    – YoungFrog
    Jan 10, 2017 at 10:33
  • @LevLamberov great, thanks for your help, one more time! Jan 11, 2017 at 8:19

You can achieve this "fast load, slow load" using the server/client functionality of emacs, which works like this:

Emacs can be started as a server. This can either be done as a stand-alone, running a server in the background. Or, if you want to, say, run a main GUI instance of emacs, the GUI and server can be started at the same time.

Once the server is started, it can be connected to using the emacsclient application, which will connect to the presently running emacs server. This is vastly faster to activate than starting emacs from scratch.

To do this:

  1. To start emacs as a server, in the background, in your terminal, issue emacs --daemon.
  2. To start the emacs server while you load emacs -- for instance, if you're using the emacs GUI, add (server-start) to your init.el (or init.el equivalent).
  3. To connect to the server, use emacsclient. To force emacsclient to open the file in question in the terminal, use the -t argument. E.g.: emacsclient -t foo.txt.

If you run Emacs as a server, you might also appreciate having a command to stop running it: emacsclient -e '(kill-emacs)'.


FWIW, here's what I do:

in ~/.emacs I define a function full-fledged-emacs which has settings which only apply to when I start my main Emacs session.

So if I start a "normal" emacs <file> those settings aren't applied. And when I want to start my main Emacs session, I do emacs -f full-fledged-emacs.

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.