2015-11-09 05:21:26 +00:00
|
|
|
#+TITLE: Spacemacs Layouts configuration layer for Spacemacs
|
2015-11-08 18:04:44 +00:00
|
|
|
#+HTML_HEAD_EXTRA: <link rel="stylesheet" type="text/css" href="../css/readtheorg.css" />
|
2015-06-10 16:44:30 +00:00
|
|
|
|
2015-10-30 11:20:58 +00:00
|
|
|
* Table of Contents :TOC_4_org:noexport:
|
|
|
|
- [[Description][Description]]
|
|
|
|
- [[Install][Install]]
|
|
|
|
- [[Layer][Layer]]
|
2015-09-30 14:08:39 +00:00
|
|
|
- [[Features ][Features ]]
|
|
|
|
- [[Micro-states][Micro-states]]
|
2015-11-09 05:21:26 +00:00
|
|
|
- [[Layouts Micro State][Layouts Micro State]]
|
2015-11-11 21:27:33 +00:00
|
|
|
- [[Project Layouts][Project Layouts]]
|
2015-11-09 05:21:26 +00:00
|
|
|
- [[Custom Layouts Micro State][Custom Layouts Micro State]]
|
|
|
|
- [[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
|
|
|
|
To use this contribution add it to your =~/.spacemacs=
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2015-11-09 06:38:47 +00:00
|
|
|
(setq-default dotspacemacs-configuration-layers '(spacemacs-layouts))
|
2015-06-10 16:44:30 +00:00
|
|
|
#+END_SRC
|
|
|
|
|
2015-09-30 14:08:39 +00:00
|
|
|
* Features
|
|
|
|
|
|
|
|
** Micro-states
|
2015-11-09 05:21:26 +00:00
|
|
|
*** TODO Layouts Micro State
|
|
|
|
The layouts micro-state is initiated with ~SPC l~.
|
|
|
|
|
2015-11-11 04:38:31 +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 |
|
|
|
|
| ~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 |
|
2015-11-09 05:21:26 +00:00
|
|
|
|
2015-11-11 21:27:33 +00:00
|
|
|
*** Project Layouts
|
|
|
|
To create a layout for a specific project use ~SPC p l~.
|
|
|
|
|
2015-11-09 05:21:26 +00:00
|
|
|
*** 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:
|
2015-09-30 14:08:39 +00:00
|
|
|
| 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-09-30 14:08:39 +00:00
|
|
|
|
2015-11-09 05:21:26 +00:00
|
|
|
**Note:** You can add more custom perspectives by using the
|
2015-11-09 04:51:29 +00:00
|
|
|
~spacemacs|define-custom-layout~ macro explained further below.
|
2015-09-30 14:08:39 +00:00
|
|
|
|
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-09-30 14:08:39 +00:00
|
|
|
|
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-09-30 14:08:39 +00:00
|
|
|
|
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-09-30 14:08:39 +00:00
|
|
|
|
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-09-30 14:08:39 +00:00
|
|
|
|
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>"
|
2015-09-30 14:08:39 +00:00
|
|
|
: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-09-30 14:08:39 +00:00
|
|
|
(...))
|
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++"
|
2015-09-30 14:08:39 +00:00
|
|
|
: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
|
2015-06-10 21:16:01 +00:00
|
|
|
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
|
2015-06-12 01:23:07 +00:00
|
|
|
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.
|