spacemacs/layers/+window-management/spacemacs-layouts/README.org

144 lines
6.5 KiB
Org Mode
Raw Normal View History

#+TITLE: Spacemacs Layouts layer
#+HTML_HEAD_EXTRA: <link rel="stylesheet" type="text/css" href="../../../css/readtheorg.css" />
2015-06-10 16:44:30 +00:00
* Table of Contents :TOC_4_org:noexport:
- [[Description][Description]]
- [[Install][Install]]
- [[Layer][Layer]]
- [[Features][Features]]
- [[Transient-states][Transient-states]]
- [[Layouts Transient State][Layouts Transient State]]
- [[Project Layouts][Project Layouts]]
- [[Custom Layouts Transient State][Custom Layouts Transient State]]
2015-11-09 05:21:26 +00:00
- [[Usage][Usage]]
- [[Save/Load layouts into a file][Save/Load layouts into a file]]
- [[Custom Layout Macro][Custom Layout Macro]]
- [[Predefined custom layouts][Predefined custom layouts]]
- [[Org-agenda custom layout][Org-agenda custom layout]]
- [[RCIRC/ERC custom layout][RCIRC/ERC custom layout]]
2015-06-10 16:44:30 +00:00
* Description
2015-11-09 05:21:26 +00:00
This contribution layer adds layouts support to Spacemacs thanks to =persp-mode=.
Layouts are window configurations that have buffer isolation between each other.
2015-06-10 16:44:30 +00:00
* Install
** Layer
This layer is automatically included if you use the =spacemacs= distribution.
2015-06-10 16:44:30 +00:00
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.
2015-06-10 16:44:30 +00:00
* Features
** Transient-states
*** Layouts Transient State
The layouts transient-state is initiated with ~SPC l~.
2015-11-09 05:21:26 +00:00
| 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 |
| ~d~ | delete the current layout and keep its buffers |
| ~D~ | delete the other layouts and keep their buffers |
| ~h~ | go to default layout |
| ~C-h~ | previous layout in list |
| ~l~ | select/create 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 current layout |
| ~s~ | save layouts |
| ~t~ | display a buffer without adding it to the current layout |
| ~w~ | workspaces transient-state (needs eyebrowse layer enabled) |
| ~x~ | kill current layout with its buffers |
| ~X~ | kill other layouts with their buffers |
2015-11-09 05:21:26 +00:00
*** Project Layouts
To create a layout for a specific project use ~SPC p l~.
*** Custom Layouts Transient State
The layouts transient-state is initiated with ~SPC l o~.
2015-11-09 05:21:26 +00:00
Example of default custom layouts that are configured in the corresponding
layers:
| Key Binding | Description |
|-------------+----------------------------------------------------------|
2015-11-09 05:21:26 +00:00
| ~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 |
2015-11-09 05:21:26 +00:00
**Note:** You can add more custom perspectives by using the
~spacemacs|define-custom-layout~ macro explained further below.
2015-11-09 05:21:26 +00:00
* Usage
At the beginning there is only one layout called =Default= which contains
all the buffers.
2015-11-09 05:21:26 +00:00
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.
2015-11-09 05:21:26 +00:00
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).
2015-11-09 05:21:26 +00:00
** 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.
2015-11-09 05:21:26 +00:00
** Custom Layout Macro
If you want to add a new custom layouts (for example if you want to have
2015-06-10 16:44:30 +00:00
IRC on its own perspective or maybe calendar or gnus) you have to use
2015-11-09 05:21:26 +00:00
the macro =spacemacs|define-custom-layout= as follows:
2015-06-10 16:44:30 +00:00
#+BEGIN_SRC emacs-lisp
2015-11-09 05:21:26 +00:00
(spacemacs|define-custom-layout "<name-to-be-shown-in-the-modeline>"
:binding "<bind-key>"
:body
(...)
2015-11-09 05:21:26 +00:00
;; (stuff to be done in the persp activating)
;; (a major mode like twittering-mode or whatever)
(...))
2015-06-10 16:44:30 +00:00
#+END_SRC
2015-11-09 05:21:26 +00:00
Other example:
2015-06-10 16:44:30 +00:00
#+BEGIN_SRC emacs-lisp
2015-11-09 05:21:26 +00:00
(spacemacs|define-custom-layout "c++"
:binding "+"
:body
(find-file "~/path/to/first/file.cpp")
(split-window-right)
(find-file "~/path/to/second/file.cpp")
2015-11-09 05:21:26 +00:00
;; (... do more stuff but be careful not to destroy the universe ...)
)
2015-06-10 16:44:30 +00:00
#+END_SRC
2015-11-09 05:21:26 +00:00
Then you can access this persp with ~SPC l o +~, where ~+~ is the binding.
2015-06-10 16:44:30 +00:00
2015-11-09 05:21:26 +00:00
** 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 [[https://www.gnu.org/software/emacs/manual/html_node/org/Agenda-commands.html][docs]].
2015-06-10 16:44:30 +00:00
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~)
2015-06-10 16:44:30 +00:00
2015-11-09 05:21:26 +00:00
*** 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.