A Walkthrough of My Spacemacs Configuration Files

My two week vacation is comming to an end. I have had one week of doing absolutely nothing productive on the computer - apart from playing around with emacs, org mode and configurations. And then I had a couple of days where I was completely home alone. I have been working on my secret project, as well as live coding some javascript canvas stuff and getting my feet wet in lisp and emacs configuration, literate programming with org-babel (oh is that the only awesome way I have worked with R).

I promised in my last post that I would share my configurations as soon as I felt I had something that was usable. I think I have this now.

The complete files are in my dotfiles repo under the emacs/spacemacs folder.

I have decided to make a quick post where I try to explain my choices and maybe give you an idea which pieces you would want yourself - and which pieces are just my insane ideas.

Layers

Personal

This is all my personal settings (functions, keyboard shortcuts) - I’ll get back to that in a little while.

Dash

I was happy to see that spacemacs comes with a dash layer out of the box. Installing this will let you open dash from the word under the cursor from any buffer in emacs with spc d d.

c-c++

This layer adds support for c, c++ and cmake all three of which I have found myself using more and more the last year.

other languages

  • ruby

  • python

  • php

  • markdown (the mode I am using right now)

  • javascript

  • html

  • go

these are all located in contrib/lang and the description of what they do, and how they can be configured should just be read there.

Things I have yet to really dig into

company-mode

a (maybe better) autocomplete mode for emacs. I have just seen people talk about it being better than the built in.

restclient

I have used paw for testing rest endpoints for quite some time now - but when I saw Emacs Rocks Episode 15 about Rest Client Mode I was in love.

I can test an endpoint by writing this in a new buffer:

GET http://hostname.tld/endpoint/name

And then use spc h M to change major mode (select rest client in the list) and then press C-c C-c to execute the command. Having a text file with executable documentation of a rest endpoint along with all small rest server projects will prove invaluable at some point I am sure.

ess

A layer for doing R programming.

Utilities

The git mode (magit) is great and the evernote intergation through geeknote will probably never really be used for anything.

Configuration

Generel stuff

This block of configuration is more or less just boilerplate stuff. I use rvm instead of rbenv (for historical reasons - convince me otherwise if you want). Tab and whitespace settings are pretty normal I think. And using cmd for meta is just required for danish keyboard, where a lot of the stuff I need to type is under a option-key-combination.

Markdown

I like to use marked to preview markdown files with. In marked 1 there was a command line utility called mark to open the file in marked with - I have made a small shellscript to do the same thing - this just links to that.

This allows me to press spc m c o to open the markdown I am currently editing in marked as well.

Org Mode settings

This big block of configuration does a couple of things.

File locations

I have decided to have my org files in dropbox. This allows me to quickly integrate with them from other places. I started out having a lot of files (one per project in gtd) - but within the first week I decided to have all my gtd like tasks grouped in in one file, and use the outlining format to organize this file into topics.

I currently have 10 sections in the main.org file

  • Tasks, for one of tasks

  • Calendar, for appointments

  • Projects, with each project under it - each having their tasks (and subtasks) beneath

  • Someday, for tasks that will happen at some point - but not yet decided

  • Maybe, for tasks that may be done at some point, but the desicion is not yet taken

  • Financial, for all tasks related to money, bills, salary, bank and so on

  • Borrowd, for all stuff I have borrowed from others, or others have borrowed from me

  • Habits, for all the recurring tasks I want to keep on doing, and track with org-habit module

  • Setup which is just a header for the gtd configuration settings for this file.

The settings

This sets some default settings (the startup fields).

And then sets some default values for various org mode variables that can be set on a task.

Effort is used to estimate the effort of a task (which aggregates up in the )

Columns is the columns I want shown in columns mode C-c C-x C-c

I have also decided on a couple of default tags (think contexts in gtd) and I have made a sequence for todo tasks.

Org mode workflow

Capturing

I capture tasks in four ways.

  • spc o t which opens org-capture

  • alfred org workflow which appends to my inbox.org file

  • mobile-org on iPhone/iPad which syncs to add entries to inbox.org file as well

  • ifttt which automatically adds stuff to inbox.org.txt

Review and refile

At least once a day I have a review session where I refile all entries in my inbox(es) to appropriate places in main.org. This is done by selecting one or more entries and pressing spc m r and selecting the destination (which can be any file in agenda-files above, and any heading at any point - up to 9 levels down). This makes it easy to file under e.g. a specific project, or maybe for filíng a task in the grocery list.

Doing

The agenda view C-c a a shows all tasks which are either scheduled or have a deadline in the comming week (or any other timeframe if the view is changed).

The quick searches also allows me to focus on a specific type of todo.

Archiving

Org mode does not delete done items. But there is a convinient function to archive done items. I do this manually once a day. (It could probably be automated - but I prefer to know how stuff works before automating it)

My Personal Layer

This layer (the first one activated in the .spacemacs file) contains my personal functions and keybindings.

Functions

Most of the functions are just easy mappings for findind a specific file or folder. And of course there have been added functions to open the function- and keybinding- files as well.

Finally it has templates for org-capture, making it easy to make a quick entry into one of the org mode files I use.

Keybindings

I decided to use spc o as prefix for (most) of my keybindings, mostly because o could be for org-mode, or for “own” - but more importantly it was not used by an existing layer (yet).

  • spc o o for opening my org dir (~/Dropbox/org)

  • spc o a for archiving done tasks in current org file

  • spc o g for opening main gtd file (~/Dropbox/org/gtd/main.org)

  • spc o j for opening my journal

  • spc o t for org capture

  • spc o n for opening my notes

  • spc o G for opening grocery list

  • spc o i for opening main inbox

  • spc o I for opening .txt version of inbox

  • spc o U for pushing to mobile org (think org UP)

  • spc o D for pulling from mobile org (thing org DOWN)

  • spc o e k for editing keybindings

  • spc o e f for editing functions

  • spc o f for changing to alternate file (e.g. from .cpp to .h)

  • spc * y for yanking to osx clipboard

  • spc * p for pasting from osx clipboard

The last two only works when running emacs as osx app (instead of in terminal, like I have run vim for the last couple of years).

Conclusion - of sorts

I still love all things emacs/spacemacs. I have not been bitten by any bugs the last couple of days at all. And I have been working a great deal since the last blogpost.

Next up

I have a couple of things I want to do. I want to create a new blogpost draft (jekyll draft) directly from emacs. And I want to be able to push it from _drafts to _posts with a single keybinding as well. Well, I guess I need to look into some more elisp programming soon.