2015-03-15 04:51:22 +00:00
|
|
|
# Perspectives contribution layer for Spacemacs
|
|
|
|
|
|
|
|
<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc/generate-toc again -->
|
|
|
|
**Table of Contents**
|
|
|
|
|
|
|
|
- [Perspectives contribution layer for Spacemacs](#perspectives-contribution-layer-for-spacemacs)
|
|
|
|
- [Description](#description)
|
|
|
|
- [Install](#install)
|
|
|
|
- [Layer](#layer)
|
|
|
|
- [Custom Perspective Macro](#custom-perspective-macro)
|
|
|
|
- [Predefined custom perspectives](#predefined-custom-perspectives)
|
|
|
|
- [-](#-)
|
|
|
|
- [Org-agenda custom perspective](#org-agenda-custom-perspective)
|
|
|
|
- [RCIRC custom perspective](#rcirc-custom-perspective)
|
|
|
|
- [Key Bindings](#key-bindings)
|
|
|
|
- [Custom Perspectives Key Bindings](#custom-perspectives-key-bindings)
|
|
|
|
|
|
|
|
<!-- markdown-toc end -->
|
|
|
|
|
|
|
|
## Description
|
2014-11-25 21:15:36 +00:00
|
|
|
|
|
|
|
This contrib layer sets up perspective-mode. And also defines custom
|
|
|
|
perspectives with a macro so that you don't have to do more steps.
|
|
|
|
|
2015-03-15 04:51:22 +00:00
|
|
|
## Install
|
|
|
|
|
|
|
|
### Layer
|
|
|
|
|
|
|
|
To use this contribution add it to your `~/.spacemacs`
|
|
|
|
|
|
|
|
```elisp
|
|
|
|
(setq-default dotspacemacs-configuration-layers '(perspectives))
|
|
|
|
```
|
|
|
|
|
|
|
|
### Custom Perspective Macro
|
2014-11-25 21:15:36 +00:00
|
|
|
|
2014-11-26 01:50:22 +00:00
|
|
|
If you want to add a new custom-persp (for example if you want to have
|
|
|
|
IRC on its own perspective or maybe calendar or gnus) you have to use
|
|
|
|
the macro `custom-persp` as follows:
|
2014-11-25 21:15:36 +00:00
|
|
|
|
|
|
|
```elisp
|
2015-03-15 04:51:22 +00:00
|
|
|
(defun custom-persp/<persp-function-name> ()
|
|
|
|
(interactive)
|
|
|
|
(custom-persp "<name-to-be-shown-in-the-modeline>"
|
|
|
|
(... stuff to be done in the persp activating a major mode like twittering or whatever ...)))
|
2014-11-25 21:15:36 +00:00
|
|
|
```
|
|
|
|
|
2015-02-06 19:11:19 +00:00
|
|
|
You can check out the layer's packages.el to see some examples of the
|
|
|
|
custom-perspectives. if you define something like this you may be able
|
|
|
|
to define a perspective with a layout.
|
|
|
|
|
|
|
|
```elisp
|
2015-03-15 04:51:22 +00:00
|
|
|
(defun custom-persp/c++-project ()
|
|
|
|
(interactive)
|
|
|
|
(custom-persp "c++"
|
|
|
|
(progn
|
|
|
|
(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 ...)
|
|
|
|
)))
|
2015-02-06 19:11:19 +00:00
|
|
|
```
|
|
|
|
|
2014-11-25 21:15:36 +00:00
|
|
|
Then you just need to add a keybinding to your custom persp, we use
|
2015-03-15 04:51:22 +00:00
|
|
|
<kbd>SPC L o [your key here]</kbd> (Perspective open <key>)
|
2014-11-25 21:15:36 +00:00
|
|
|
|
2015-03-15 04:51:22 +00:00
|
|
|
```elisp
|
|
|
|
(evil-leader/set-key "Lo<your key here>" 'custom-persp/<persp-function-name>))
|
2014-11-25 21:15:36 +00:00
|
|
|
```
|
2014-11-26 01:50:22 +00:00
|
|
|
|
2015-03-15 04:51:22 +00:00
|
|
|
## Predefined custom perspectives
|
2014-11-26 01:50:22 +00:00
|
|
|
|
2015-03-15 04:51:22 +00:00
|
|
|
#### Per project custom perpsective
|
2014-11-25 21:15:36 +00:00
|
|
|
|
2015-03-15 04:51:22 +00:00
|
|
|
As the name suggests, this persp-projectile mode creates a new perspective
|
|
|
|
once you switch to a new project with `<SPC> p s`. It must be said that in the
|
|
|
|
current implementation in order for this to work you must first open a
|
|
|
|
custom-perspective like `SPC L o e` to go to the init.el in the spacemacs.
|
2014-11-25 22:20:11 +00:00
|
|
|
|
2015-03-15 04:51:22 +00:00
|
|
|
```elisp
|
2015-03-24 04:48:08 +00:00
|
|
|
(setq-default dotspacemacs-configuration-layers '(
|
|
|
|
(perspectives :variables
|
|
|
|
perspective-enable-persp-projectile t)))
|
2015-03-13 07:34:27 +00:00
|
|
|
```
|
|
|
|
|
2015-03-15 04:51:22 +00:00
|
|
|
#### Org-agenda custom perspective
|
2015-03-13 07:34:27 +00:00
|
|
|
|
|
|
|
Here we define a custom perspective that adds items to your org-agenda if you
|
|
|
|
do not know what that is check the
|
|
|
|
[docs](https://www.gnu.org/software/emacs/manual/html_node/org/Agenda-commands.html).
|
2015-02-06 19:11:19 +00:00
|
|
|
|
2015-03-13 07:34:27 +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`)
|
2014-11-25 22:20:11 +00:00
|
|
|
|
2015-03-15 04:51:22 +00:00
|
|
|
#### RCIRC custom perspective
|
2015-03-13 07:34:27 +00:00
|
|
|
|
|
|
|
Now you can also open rcirc in a new layer to keep all the chat buffers in one
|
|
|
|
perspective isolated from your work buffers.
|
|
|
|
|
|
|
|
You will have to use the perspective layer as well as the rcirc layer:
|
|
|
|
|
|
|
|
```elisp
|
|
|
|
(setq-default dotspacemacs-configuration-layers '(rcirc
|
|
|
|
perspectives))
|
|
|
|
```
|
2015-03-15 04:51:22 +00:00
|
|
|
|
|
|
|
## Key Bindings
|
|
|
|
|
|
|
|
Prefix command for perspective commands is <kbd>SPC L</kbd> (for Layout).
|
|
|
|
|
|
|
|
Key Binding | Description
|
|
|
|
----------------------|------------------------------------------------
|
|
|
|
<kbd>SPC L A</kbd> | Add current buffer to the current perspective
|
|
|
|
<kbd>SPC L c</kbd> | Close a perspective (kill it)
|
|
|
|
<kbd>SPC L k</kbd> | Remove current buffer from the current perspective
|
|
|
|
<kbd>SPC L n</kbd> | Next perspective
|
|
|
|
<kbd>SPC L p</kbd> | Previous perspective
|
|
|
|
<kbd>SPC L r</kbd> | Rename current perspective
|
|
|
|
<kbd>SPC L s</kbd> | Switch to a perspective
|
|
|
|
|
|
|
|
### Custom Perspectives Key Bindings
|
|
|
|
|
|
|
|
Key Binding | Description
|
|
|
|
----------------------|------------------------------------------------
|
|
|
|
<kbd>SPC L o e</kbd> | Emacs custom perspective
|
2015-03-24 04:48:08 +00:00
|
|
|
<kbd>SPC L o i</kbd> | RCIRC custom perspective (needs the rcirc layer enabled)
|
2015-03-15 04:51:22 +00:00
|
|
|
<kbd>SPC L o o</kbd> | Org custom perspective
|