Updated March 18, 2021
Emacs users write custom code for their software. Each 'configuration' can be highly individualized. Because some custom configurations take longer to load than others, Emacs users like to minimize and measure their 'load' time.
The software loads like any other software, loading libraries included in the core, and then additional libraries according to various configuration files. With Emacs, these files are stored in various locations based on the settings specified by the user, and the system Emacs is installed on.
There is an 'XDG_CONFIG_HOME' location, for Linux (and possibly also Mac, though I haven't looked into that), and the traditional locations in what is called the 'home' directory, or the .emacs.d directory.
On Windows, I will usually build a configuration in a directory directly off the c drive, "C:/emacs-27.1", and this will become the 'home' directory. On linux, software installations frequently clutter the system's home directory (with hidden . files), and a lot of user specific configuration files are stored in the '.config/' directory, off of the 'home' directory. This is commonly called the 'dotfiles' directory.
Emacs will look for three files, 'early-init.el' and '.emacs' or 'init.el' in various directories according to this specification:
However, Emacs will still initially look for init files in their traditional locations if "~/.emacs.d" or "~/.emacs" exist, even if '$XDG_CONFIG_HOME/emacs' also exists. This means that you must delete or rename any existing '~/.emacs.d' and '~/.emacs' to enable use of the XDG directory.
If '~/.emacs.d' does not exist, and Emacs has decided to use it (i.e. '$XDG_CONFIG_HOME/emacs' does not exist), Emacs will create it. Emacs will never create '$XDG_CONFIG_HOME/emacs'.
Whichever directory Emacs decides to use, it will set 'user-emacs-directory' to point to it.
'.el' files are elisp, emacs programming language files. They are compiled into '.elc' files, which if speficied in the initilization code load first always if present. 'early-init.el' is a file that loads before '.emacs' or 'init.el,' which are two ways of specifying the same initialization file, that is, the main configuration file where users put their specialized code.
I don't bother much with the 'early-init.el,' however, the following code is recommended.
The next few sections are init.el, loaded from the same directory as early-init.el (in my case 'c:\emacs-27.1\.emacs.d\emax')
An Emacs package called "Org-Mode," provides a lot of functionality. One thing you can do with it is specify sections of an "org" file (file.org), with code delimiters, and later 'tangle' them into other files, with specified file extensions. Incidentally, you can also run the code in those sections and pass the results in a variety of ways.
Org-mode provides a utility called "org-babel" that is commonly used to extend and organize an "init.el" file. In init.el above, for example, I extend the init.el file to files named wemax.el, wslmax.el, or lemax.el, depending on their existence and the system I am using. If they do not exist (or if I specify it), the org files with my customized configuration code, wemax.org, lemax.org, or wslemax.org are 'tangled' into the system appropriate .el files.
I therefore work on my configuration code in an org file, which provides all the advantages of using an org file, and configure that file to 'tangle' into the .el files when I exit emacs. This is a standard feature of 'literate programming', a fancy name I suppose for using the org-babel package to manage your emacs configuration (or other coding tasks.)
The code above sets a package directory, the user-emacs-directory (.emacs.d), variables for the init files, and in the windows case some load-paths (I'm working mostly on my windows system right now, so I've yet to bring my linux and wsl configs up to full speed).
This guy above loads the use-package package when it's not on the system. 'Use-package' provides many utilities for easily loading and configuring various Emacs packages (add-on software).
To use this code intelligently, you will need to research every line. If that doesn't make sense for you - and it shouldn't unless computer science is something you are into or want to get into - find a consultant or friend to explain how it all works, and set you up with a working system. Someone, for example, like me. 😊
A 'load-path' tells your software where to look for programs and libraries. On Windows, when you add software you can add it to your load-path using environment variables. If you use Chocolatey package manager it is added automatically and your load-path line limit is extended. Now you can access programs from the command line, without changing shell location to the program's root directory. To add this load path to Emacs, you need some specialized code (included on this page).
On Linux to add the load-path to Emacs you can use the package, Exec-path-to-shell, specified above.
Also above are 'diminish,' which compresses package names for your information bar (called the modeline), and 'bind-key,' which provides some improved syntax and functionality for configuring short-cuts, which are a central part of Emacs (the name 'Emacs' is actually short I think for "Elisp Macros", which are essentially short-cuts).
I use the garbage collection hack
The garbage collection hack can speed up your operations. Read up on it. Server auth is redefined later for lemax, and wslmax, still have to reorganize those two files (but not wemax.org, which is right now an awesome file 😏 )
Note: that last chunk of code above loads the variable init-el, which is the compiled wemax.el, lemax.el, or wslemax.el, depending on the system, if it exists. If it doesn't exist, it tangles your wemax.org, lemax.org, or wslemax.org
I also want to include in this post the byte-compiling functions, as well as the exit function, which are key for reducing load-time to 3 seconds.
Note: Of course this can be confusing if you don't know what you are looking for. If that is the case, you can ask me for more explanation. Otherwise, make a plan for exactly what you want to get out of Emacs, then, if you want to go big, start with System Crafters on youtube.
Remember, learning and using Emacs, which after all is said and done can improve your technical and knowledge working capacity multiple times over, can be a simple and smooth process, taking only a few easy years, or a stressful and confusing nightmare taking up to a decade. Think about what you want to get out of it, and consult someone who knows what they are doing.
Byte compiling code enables your computer to load it much more quickly. Above are some byte compiling functions I use. I usually tangle my entire configuration whenever I change it, and byte-compile the directory it's in occasionally.
These functions above are used to exit Emacs. They run some code at exit time. You can ignore the command-log-mode stuff, it's only relevant if you're writing your command log to a file.
Also, the Mingus code is of course only if you have Mingus set up as I do.
In the case where you are using a daemon and a client, you can exit with the instance. Lately I'm loading calendar and news buffers on load, so I'm no longer using the emacs daemon as much.
Below is the original text for this post, which is around a year before this updated text was added. Feel free to browse that also.
Below are some notes covering among other things why I got into Emacs, where I got my version, and how my configuration is organized. As mentioned before, other text editors in use today, like Atom, IntelliJ Idea, or Sublime Text are awesome, and offer also great selections of unique packages. Atom, for example, has some super useful snippet packages. You can convert them into Yasnippet format (an Emacs snippet package), but it's a hassle. So there are a lot of reasons not to use Emacs.
Having said that, and despite the fact Emacs is written in the widely used Elisp language, I use it and promote it. Here's why. Emacs has an incredibly clean feel. Properly configured, it's simple, unencumbered text with all the function of an IDE and more. Plus, it's old sKool, with a capital K.
I first got into Emacs in 2013. After five or six years of part-time college in sciences and arts, and many years in industry in a variety of positions, including business owner, I went back to university in 2009 to finish my bachelors degree. Having finished Adam Smith's "The Wealth of Nations," but stumbled on Keynes' "The General Theory of Employment, Interest And Money" I majored in economics. As much as the theory at what is now The Vancouver School of Economics was excellent, on the data and programming side our courses disappointingly veered away from computer science. While at one point we were introduced to the R GUI, in general we were taught Stata, and I did most of my work with Excel, Word, or Open Office.
After graduation, I wound up working with General Equilibrium Modelling Software (GAMS), one of the frameworks used to solve equilibrium models. My supervisor introduced me to Emacs and Emacs Speaks Statistics (ESS), the Emacs alternative to the R GUI or Rstudio, as well as the Emacs GAMS package, now available on Melpa.
A large part of my job was to clean and sort data using Excel and Microsoft Access, but it was easier to find and fix missing observations in R, using ESS. I ended up exploring the Emacs initialization file looking for ways to improve data cleaning efficiency. That's often how the Emacs experience starts - passed on through academic circles.
Quickly I ran into time constraints and came with up Vincent Goulet's pre-configured Emacs installation as a way to save time. It comes at least for now compiled for Windows with a Latex engine and an included R configuration. Still, if you want Image Magick or PDF Tools support, you'll want something else. I'll get to that.
The evolution of every Emacs configuration is too long of a story. It's a trial and error process. Emacs at its best is like an operating system in an operating system. You're building a car (well, a workshop) from second hand parts. You've got to find them, fit them, run them, fix them, and make new ones when you need them. Everything is built in a variation of lisp called elisp, and while lisp is a cool language with a cool history, it's basically useless for anything other than programming theory or specialized bottom-up stuff like Emacs.
You can get from a blank initialization to a fully operational emacs installation without taking a single lisp course, but if I were to start again, I'd take a week or two and do a crash course in lisp. Now I'm not an expert programmer. I've so far covered too many subjects for that. If I were a genius, which I'm not, I'd be a polymath. But, after eight years of programming, I know a good resource when I see it. The late Robert J. Chassel's "An Introduction To Programming In Emacs Lisp" is one such resource. A week in there will get any beginning Emacs enthusiast well ahead of the game.
Another one, for the advanced and ambitious lisp enthusiast, was written by the quite famous programmer, writer, and investor Paul Graham, founder of Ycombinator one the incubators behind such startups as "Dropbox," "Airbnb," "Zapier," "Gitlab," and "Docker." You can buy Paul's book "On Lisp, Advanced Techniques for Common Lisp" from Amazon for $154 USD, or you can download essentially the same thing for free from his website here. Either way, a week in there will get you a great introduction to some foundational programming language theory through lisp.
Emacs configurations get hefty and drag on load time. There are ways around this. You can, for example, run Emacs as a server, in which case the process is always on and doesn't need to load when you start, or you can optimize the load time. Another way around is to use a Linux distro. A lot of Emacs packages are written for Unix and spawn a lot of processes, which slows things down on the Windows NTFS backed file system. If you're just starting out, Linux is anyway a headache well worth your time. But, if you're like me, a long time Windows user, and you want to get the most out of Emacs, you'll need a few resources.
Windows Subsystem Linux, with VirtualBox or X Server is one way to run an Emacs configuration that does more than a Pico or Nano on your windows machine. I use Ubuntu on WSl, but I haven't gotten around to running graphics programs on it. I'm still using Emacs on the Windows system. Other than the start-up time, usually a one-time cost, it's not slow enough for me to notice. Even with a reasonable amount of RAM however any work on data with more than a million records would be more efficiently done on the Linux system.
There are a few other things you'll want to do to speed up Emacs on Windows. One is to defer load times in your initialization with
:interpreter, from Emacs Use-Package, another does the same with conditional calls to code chunks in your configuration, using something like
(eval-after-load 'example-mode '(require 'setup-example-mode)).
Also, if you're using Org-babel in your initialization to separate the code you want to send to the interpreter or compiler from text you want to write or send to the web, you'll want to remember the more separate chunks you tangle the slower the load time. Ideally you would have two versions of your init file, one with lots of organized code chunks for folding and editing easily, and another with one code chunk to optimize load time.
Finally, if you're running Emacs on a windows system, you'll want to run a version that is compiled for windows. This will give you access to useful linux libraries. Today, I'm using a window's compiled version I found on the web last year that supports PDF Tools and Image Magick. Way Cool. The next section is from the notes I took about the Emacs version I found. I don't know the guy who compiled it. I just use his distro.
Windows Emacs Installation
a better emacs exe is compiled with imagemagick support, pdftools support, and other libraries sourced from Mingw64. "XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS MODULES THREADS LCMS2"
Here are the links to his version and patches:
I prefer to install to c://, as that is what I'm used to.
64-bit Windows build of Emacs 26.2 final release.
Patched with ImageMagick 7 support. Binaries and libs included.
PDF-TOOLS (epdfinfo.exe) included. [emax.7z package]
Features: "XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS MODULES THREADS LCMS2"
Optimized clean build. Options: "--without-compress-install --without-dbus --with-modules 'CFLAGS= -O2 -g3'"
Built and tested on a clean Windows 10 system.
addpm modified to not create/update any registry HOME entries. It only creates shortcuts as it should.
 C-h v system-configuration-features
 C-h v system-configuration-options
Unpack the 7z binary archive, preferably in C:\ root directory.
Double-click the addpm.exe file in emax64\bin to create/update shortcuts.
installation instructions for msys2, which provides a bash shell and other linux tools for windows, and is a windows programming tool http://www.msys2.org/-
Install MSYS2 [64-bit: http://repo.msys2.org/distrib/msys2-x86_64-latest.exe]-
Download and unpack emax.7z into your HOME directory, usually C:\Users\
emax.7z is an environment to make your Emacs experience a little more tolerable on Windows.-
It includes a barebones dotfile along with BusyBox 64-bit, some MinGW packages, SSH, W3M, Aspell, and other GNU tools to help you start right away.
GNU Emacs sources, patched as described above, are available as a separate src archive.
All the other binaries included in the emax64 and emax archives are unmodified and distributed as is.
Their sources can be downloaded from MSYS2/MinGW servers: http://repo.msys2.org/mingw/sources/
BusyBox (Windows) sources can be obtained from here: https://frippery.org/files/busybox/
An Emacs initialization file calls and configures packages (libraries). Like any other program resources need to be loaded into namespaces in order, so they can be found when called on. One of the more popular Emacs packages is called Org-Mode. "Org" is for "organization," but when I hear the name I think of "Origami," because org-mode has cool section folding.
One of the libraries affiliated with Org-mode is called Org-babel. It enables labelled section chunks to be sent to the interpreter or compiler. With Org-babel you can put your entire initialization file into one .org file. You can then fold it to navigate it, interpret it, or compile it for faster loading.
The following elisp sets up my initialization file, which is called on line ~129 with
org-babel-load-file. This goes in the .emacs file in your root emacs directory. I'll add to the comments before the code to explain them. I'm a fan of both GPL and BSD, but it's hard to argue with the merits of the free license Manish Parashar has used in his configuration here. Pardon any overkill, I was in a hurry so I just threw Parashar's .emacs together with mine. They were essentially the same, with some minor syntax changes.
The code above is the opening to the init file. Mine is a big one. The rest of it is stored in my case here:
"c:/emacs/emax/emax.org" (whereas the section above is stored here:
"C:/emacs/.emacs"). "emax.org" is folded origami style. In later posts, I want to go through quickly each of the sections. So next I'm going to introduce you to the folded headings. When the document is open in Emacs, you hit 'tab' with the cursor ('point') over the section heading and it will toggle the contents to drop down.
MY INITIALIZATION FILE
- SET UP, DEFAULTS, AND CUSTOMIZATION
- Default Operations
- Selection region and Mark
- Finding Files
- ediff improvements
- Finding Differences in Files With Diff
- THE HELM HYDRA
- Web Developer Hydra
- Program Launcher
- WEB MODE
- PHP Mode
- CSS Mode
- Easy Hugo
- Configure your code (test)
- Pretty insane company configuration
- Json syntax highlighting
- Comment/uncomment block
- Text mode
- Git Magit Hydra
- Auctek, Miktex, Latex
- CSV Mode
- MYSQL (SQL MODE)
- ESS Mode
- Yaml Mode
While most of the above is operational, there are a lot of areas I've set up but haven't gotten around to testing. Basically, whenever I do any work I keep notes explaining how I did it. In most cases, I've taken those notes and turned out some Elisp to automate the process, but in quite a few cases I haven't gotten around to it and haven't had to use it again. But, it's 80% done, and when I get the time I'll finish it off, optimized it, and publish it to the net. Below is an image of the same, for good measure.