Personal emacs settings
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

README Emacs configuration

This is the GIT-repository for my (Gustav Wikström) Emacs customizations and some information and links regarding the editor.

My settings are supposed to work both for linux, windows and mac, although I don’t use mac anymore so I will not claim it works there any longer.

The settings are adapted for Emacs 25.

About Emacs

Emacs is a texteditor within GNU with a GPL licence and is thus free to use and free to hack.

When just learning about it is recommended to first work ones way through Emacs-tutorial. Click on the link or use the commando:

  • C-h t

(only works inside emacs ofc)

Also.. A BIG prerequisit before starting to use Emacs is to move (or copy) the Ctrl-key to the Caps Lock key on modern keyboards. Really. It has to be done.

Installation of Emacs


  • Download the latest version fo Emacs.

    or alternatively from the unofficial 64-bit build which also includes newer bin-files for inline images etc.:

  • Unpack it to Dropbox/Mjukvara/Emacs/
  • Control that the environment-variable %HOME% is defined for the current user. Make sure it’s set to c:\users\[username] (the same path as %HOMEPATH% (but not %HOMEPATH% it self, that seems not to work). Check what the variable is defined as by writing:
    echo %HOMEPATH%

    in a command-prompt. (see (info "(emacs)Find init") for more information about %HOME%)

  • Make folder junctions and symbolic links for Emacs and my customization repository. See: #Linking files.
  • Check all the “installation”-tags in the *.org documents in the .emacs.d-folder.


Either use the version that exists as a package by default (not up to date), use a separate repository or build it from source-code. See [fn:1], [fn:2], or [fn:3].

[fn:1] [fn:2] [fn:3]

for version 24.3

Use link [fn:2]. To add his PPA:

$ sudo add-apt-repository ppa:cassou/emacs
$ sudo apt-get update


$ sudo apt-get install emacs24

for version 24.4

Use link [fn:3] (install from source-code).

  1. Disinstall previous version
    sudo apt-get remove --purge emacs24
    1. Remove the special repository from where 24.3 was installed
      sudo add-apt-repository --remove ppa:cassou/emacs


  2. Download the source-code and unpack
    cd ~
    mkdir emacs-src && cd emacs-src
    tar xvf emacs-24.4.tar.gz
  3. compile
    sudo apt-get install build-essential
    sudo apt-get build-dep emacs24
    cd emacs-24.4
    sudo make install

for version 25.1

  1. Deinstall previous version. Since I’ve removed the source already I’ll recreate it according to
    mkdir emacs-src && cd emacs-src
    tar xvf emacs-24.4.tar.gz
    cd emacs-$VERSION
    ./configure --with-jpeg=no
    make uninstall
  2. Download the source-code and unpack
    tar xvf emacs-25.1.tar.xz
  3. Kompilera och installera. Jag kollade på:

    för att få det avinstallerbart

    sudo apt install build-essential checkinstall
    sudo checkinstall
  4. Kan sen avinstalleras med (för mig alltså)
    sudo dpkg -r emacs

Setup of Emacs

Introduction and system-description

The Emacs-configuration is stored a folder on Dropbox named Mjukvara. Files and catalogs here are linked to the system-catalogs they are supposed to be seen as by the system (see #Linking files below). On windows and linux they are supposed to reside in a folder called ~/.emacs.d/. The files my configuration is build upon are:
windows-specific settings
linux-specific settings
specific settings per computer.
main default settings
specific settings, loaded in the end.

Other than those files there are also a few catalogs with plugins and files relating to these plugins:

for plugins managed by ELPA.
for plugins installed manually or with el-get.
for snippets usable with yasnippet. is used to initialize the settings and make the initialization know in which order the rest of the files are to be loaded.

The settings are coded in “literate programming”-style.


GIT is used as a revision-control-system for my settings.

Misc. Guides & Instructions

Linking files from Dropbox to emacs load paths


General instructions

  • Open up the command line as administrator (right click, choose “open as administrator”)
  • Use the command MKLINK to symbolacally link files between the folders, example:
    > MKLINK "c:\symbolic link.txt" "c:\other directory\textfile.txt"

    Symbolic links has a drawback, they will not be updated when the source-file is updated. The consequence is that each time a change is added to a source org document, the file needs to be tangled manually. Hard links are better, but they do not work with Dropbox.

  • Use the command MKLINK with option /J to create a junction for folders to be linked. Example:
    > MKLINK /J "c:\junction folder\" "c:\existing folder\"

Run in batch

Change the variables in the following example and execute the code in a “.bat” file. The code must be executed by a administrator for it to be applied (MKLINK is restricted otherwise).

Make sure the files init-pre_*.org and init-end_*.org exists, where * is the name of your computer.

set version_nr=25.1
set emacs_folder=%HOMEDRIVE%\emacs\
set dest_folder=%HOME%\.emacs.d
set src_folder=%HOMEPATH%\Dropbox\Mjukvara\Emacs
set computer=%COMPUTERNAME%

MKLINK /J "%emacs_folder%"              "%src_folder%\emacs-%version_nr%"
MKDIR %dest_folder%
MKLINK /J "%dest_folder%\org-mode"      "%src_folder%\org-mode"
MKLINK /J "%dest_folder%\plugins"       "%src_folder%\.emacs.d\plugins"
MKLINK /J "%dest_folder%\snippets"      "%src_folder%\.emacs.d\snippets"
MKLINK /J "%dest_folder%\elpa"          "%src_folder%\.emacs.d\elpa"
MKLINK "%dest_folder%\"         "%src_folder%\.emacs.d\"
MKLINK "%dest_folder%\"    "%src_folder%\.emacs.d\"
MKLINK "%dest_folder%\" "%src_folder%\.emacs.d\"
MKLINK "%dest_folder%\"     "%src_folder%\"
MKLINK "%dest_folder%\"     "%src_folder%\"


A script with the code above is created in the src_folder defined in the script to simplify the deployment of emacs.



if [ ! -d ${dest_folder} ]; then
  mkdir ${dest_folder}
ln -s ${src_folder}/.emacs.d/plugins                      ${dest_folder}/plugins
ln -s ${src_folder}/.emacs.d/snippets                     ${dest_folder}/snippets
ln -s ${src_folder}/.emacs.d/elpa                         ${dest_folder}/elpa
ln -s ${src_folder}/.emacs.d/                     ${dest_folder}/
ln -s ${src_folder}/.emacs.d/                ${dest_folder}/
ln -s ${src_folder}/.emacs.d/               ${dest_folder}/
ln -s ${src_folder}/init-pre_${computer}.org              ${dest_folder}/
ln -s ${src_folder}/init-end_${computer}.org              ${dest_folder}/

Emacs-server / emacsclient

Run emacsclient in windows

(Recommended) Method 1 - Use a environment variable as fallback and only call the client

Taken from [fn:4].


This method seems to be the recommended way according to the link. You make sure to associate files with emacsclientw.exe and create an environment variable to redirect to runemacs.exe if there is no emacs-server running. The parameter is called ALTERNATE_EDITOR.



For this to work the init-files for windows has to also run the command:


Method 2 - Create fileassociations and custom links

Uses information in [fn:5].


  • Change the calls to emacs with custom links to run emacsclient with fallback on normal emacs:
    C:\emacs\bin\emacsclientw.exe -n --alternate-editor="C:\emacs\bin\runemacs.exe" -c

    Can also be stored as a .bin-file in the emacs-bin folder and used instead of emacsclientw.exe or runemacs.exe when starting emacs.

    @echo off
    "%~dp0emacsclientw.exe" -na "%~dp0runemacs.exe" "%1"
  • Update the default-program to run emacsclientw.exe in the same way. This was more difficult!

    Remove existing information about default-programs for .txt in the registry using regedit. Some examples of keys I removed:


    Update default programs and associations with ftype and assoc :

    set bin=%HOMEDRIVE%\emacs\bin
    ftype txtfile=%bin%\emacsclientw.exe -na %bin%runemacs.exe "%1" -c
    assoc .txt=txtfile

Emacs convensions

All functions and variables that are defined by me shall have the prefix gw/ in the name. This will work as a sort of “namespace”.