Personal emacs settings
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitattributes
.gitignore
README.org
init-end_template.org
init-linux.org
init-main.org
init-pre_template.org
init-windows.org
init.org

README.org

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

Windows

  • 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/Emacs-verson.nr.
  • 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.

Ubuntu

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] https://launchpad.net/~cassou/+archive/emacs [fn:2] http://ubuntuhandbook.org/index.php/2013/09/install-upgrade-to-emacs-24-3-in-ubuntu-13-04-12-10-12-04/ [fn:3] http://askubuntu.com/questions/437255/how-to-install-emacs-24-4-on-ubuntu

for version 24.3

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

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

Then:

$ 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
              

      (See http://askubuntu.com/questions/307/how-can-ppas-be-removed)

  2. Download the source-code and unpack
    cd ~
    mkdir emacs-src && cd emacs-src
    wget http://ftp.gnu.org/gnu/emacs/emacs-24.4.tar.gz
    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
    ./configure
    make
    sudo make install
        

for version 25.1

  1. Deinstall previous version. Since I’ve removed the source already I’ll recreate it according to http://askubuntu.com/a/648917.
    mkdir emacs-src && cd emacs-src
    wget http://ftp.gnu.org/gnu/emacs/emacs-24.4.tar.gz
    tar xvf emacs-24.4.tar.gz
        
    cd emacs-$VERSION
    ./configure --with-jpeg=no
    make
    make uninstall
        
  2. Download the source-code and unpack
    wget http://ftp.gnu.org/gnu/emacs/emacs-25.1.tar.xz
    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
    ./configure
    make
    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:

file:init.org
bootstraping
init-windows.org
windows-specific settings
init-linux.org
linux-specific settings
init-pre.org
specific settings per computer.
init-main.org
main default settings
init-end.org
specific settings, loaded in the end.

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

elpa/
for plugins managed by ELPA.
plugins/
for plugins installed manually or with el-get.
snippets/
for snippets usable with yasnippet.

init.org 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.

Versioning

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

Misc. Guides & Instructions

Linking files from Dropbox to emacs load paths

Windows

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%\init.org"         "%src_folder%\.emacs.d\init.org"
MKLINK "%dest_folder%\init-main.org"    "%src_folder%\.emacs.d\init-main.org"
MKLINK "%dest_folder%\init-windows.org" "%src_folder%\.emacs.d\init-windows.org"
MKLINK "%dest_folder%\init-pre.org"     "%src_folder%\init-pre_%computer%.org"
MKLINK "%dest_folder%\init-end.org"     "%src_folder%\init-end_%computer%.org"

PAUSE

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

Linux

#!/bin/sh
dest_folder=~/.emacs.d
src_folder=~/Dropbox/Mjukvara/Emacs
computer=$(hostname)

if [ ! -d ${dest_folder} ]; then
  mkdir ${dest_folder}
fi
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/init.org                     ${dest_folder}/init.org
ln -s ${src_folder}/.emacs.d/init-main.org                ${dest_folder}/init-main.org
ln -s ${src_folder}/.emacs.d/init-linux.org               ${dest_folder}/init-linux.org
ln -s ${src_folder}/init-pre_${computer}.org              ${dest_folder}/init-pre.org
ln -s ${src_folder}/init-end_${computer}.org              ${dest_folder}/init-end.org

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].

[fn:4] http://www.gnu.org/software/emacs/manual/html_mono/efaq-w32.html#Associate-files-with-Emacs

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.

SETX ALTERNATE_EDITOR "runemacs.exe"

PAUSE

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

(server-start)

Method 2 - Create fileassociations and custom links

Uses information in [fn:5].

[fn:5] http://www.emacswiki.org/emacs/EmacsMsWindowsIntegration

  • 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:

    [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts]
    [HKEY_USERS\S-1-5-21-4021217801-3181878105-1416941158-1001\Software\Microsoft\Windows\Roaming\OpenWith\FileExts\.txt]
    [HKEY_CURRENT_USER\Software\Microsoft\Windows\Roaming\OpenWith\FileExts\.txt]
    [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.txt]
        

    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”.