This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
spacemacs/layers/+window-management/spacemacs-layouts
Eivind Fonn c893383fe4 Fix some documentation bugs
- CSS links
- GIFS in published version
- Unify layer doc titles
- Change emoji layer emojis to an image
2015-12-03 23:50:29 -05:00
..
config.el perspectives: rename layer to "spacemacs-layout" 2015-11-09 00:36:13 -05:00
funcs.el layouts: fixes reset of layout upon creation of new layouts 2015-11-11 01:20:18 -05:00
packages.el Add key binding for saving perpectives by names 2015-11-23 20:01:22 +01:00
README.org Fix some documentation bugs 2015-12-03 23:50:29 -05:00

Spacemacs Layouts layer

Description

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

Install

Layer

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

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

Features

Micro-states

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

Project Layouts

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

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.

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

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.

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>"
    :body
    (...)
    ;; (stuff to be done in the persp activating)
    ;; (a major mode like twittering-mode or whatever)
    (...))

Other example:

  (spacemacs|define-custom-layout "c++"
    :binding "+"
    :body
    (find-file "~/path/to/first/file.cpp")
    (split-window-right)
    (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.

Predefined custom layouts

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)

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.