Skip to content

Latest commit

 

History

History
142 lines (119 loc) · 6.34 KB

File metadata and controls

142 lines (119 loc) · 6.34 KB

Spacemacs Layouts layer

Table of Contents

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

This layer is automatically included if you use the spacemacs distribution.

If you use spacemacs-base distribution then to use this configuration layer, add it to your ~/.spacemacs. You will need to add spacemacs-layout to the existing dotspacemacs-configuration-layers list in this file.

Features

Micro-states

Layouts Micro State

The layouts micro-state is initiated with SPC l.

Key BindingDescription
?toggle the documentation
[1..9, 0]switch to nth layout
<tab>switch to the latest layout
aadd a buffer to the current layout
Aadd all the buffers from another layout in the current one
bselect a buffer in the current layout
cclose the current layout and keep its buffers
Cclose the other layouts and keep their buffers
hgo to default layout
C-hprevious layout in list
lselect a layout with helm
Lload layouts from file
C-lnext layout in list
nnext layout in list
Nprevious layout in list
oopen a custom layout
pprevious layout in list
rremove current buffer from layout
Rrename layout
ssave layouts
tdisplay a buffer without adding it to the current layout
xkill current layout with its buffers
Xkill 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 BindingDescription
eEmacs custom perspective
EERC custom perspective (needs the erc layer enabled)
iRCIRC custom perspective (needs the rcirc layer enabled)
oOrg 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.