Table of Contents

Spacemacs Layouts configuration layer for Spacemacs

Table of ContentsClose

1 Description

This contribution layer adds layouts support to Spacemacs thanks to persp-mode. Layouts are window configurations that have buffer isolation between each other.

2 Install

2.1 Layer

To use this contribution add it to your ~/.spacemacs

(setq-default dotspacemacs-configuration-layers '(spacemacs-layouts))

3 Features

3.1 Micro-states

3.1.1 TODO Layouts Micro State

The layouts micro-state is initiated with SPC l.

Key Binding Description
? toggle the documentation
[1..9, 0] switch to nth layout
<tab> switch to the latest layout
a add a buffer to the current layout
A add all the buffers from another layout in the current one
b select a buffer in the current layout
c close the current layout and keep its buffers
C close the other layouts and keep their buffers
C-h previous layout in list
l select a layout with helm
L load layouts from file
C-l next layout in list
n next layout in list
N previous layout in list
o open a custom layout
p previous layout in list
r remove current buffer from layout
R rename layout
s save layouts
t display a buffer without adding it to the current layout
x kill current layout with its buffers
X kill other layouts with their buffers

3.1.2 Project Layouts

To create a layout for a specific project use SPC p l.

3.1.3 Custom Layouts Micro State

The layouts micro-state is initiated with SPC l o.

Example of default custom layouts that are configured in the corresponding layers:

Key Binding Description
e Emacs custom perspective
E ERC custom perspective (needs the erc layer enabled)
i RCIRC custom perspective (needs the rcirc layer enabled)
o Org custom perspective

Note: You can add more custom perspectives by using the spacemacs|define-custom-layout macro explained further below.

4 Usage

At the beginning there is only one layout called Default which contains all the buffers.

If you keep working within this layout then Emacs behaves as if layouts don't exist so you are never forced to use them even if they are available.

They are two types of layouts:

  • regular layouts which you can create dynamically or which can be bound to a projectile project (press SPC l to access them)
  • custom layouts which are defined with the macro spacemacs|define-custome-layout and always active (press SPC l o to access them).

4.1 Save/Load layouts into a file

With SPC l s and SPC l L you can save and load perspectives to a file. This is available without configuration, support is great for emacs 24.4, but depends on workgroups.el for Emacs <= 24.3.

4.2 Custom Layout Macro

If you want to add a new custom layouts (for example if you want to have IRC on its own perspective or maybe calendar or gnus) you have to use the macro spacemacs|define-custom-layout as follows:

(spacemacs|define-custom-layout "<name-to-be-shown-in-the-modeline>"
  :binding "<bind-key>"
  ;; (stuff to be done in the persp activating)
  ;; (a major mode like twittering-mode or whatever)

Other example:

(spacemacs|define-custom-layout "c++"
  :binding "+"
  (find-file "~/path/to/first/file.cpp")
  (find-file "~/path/to/second/file.cpp")
  ;; (... do more stuff but be careful not to destroy the universe ...)

Then you can access this persp with SPC l o +, where + is the binding.

4.3 Predefined custom layouts

4.3.1 Org-agenda custom layout

Here we define a custom layout that adds items to your org-agenda. If you do not know what that is check the docs.

The cool part is that you can have many org files with todos in the agenda and with one simple command you can gather all the todos from all the agenda files you have and show them in a single buffer. (in evil the command starts with ;a)

4.3.2 RCIRC/ERC custom layout

Now you can also open IRC in a new layout to keep all the chat buffers in one layout isolated from your work buffers.

Created: 2015-12-02 Wed 14:45