From a721dc55fecd27917678f607083faa62fc3c5ae7 Mon Sep 17 00:00:00 2001 From: syl20bnr Date: Sun, 15 Mar 2015 00:51:22 -0400 Subject: [PATCH] Refactor prespecitves layer README and move key bindings on L prefix --- contrib/perspectives/README.md | 131 ++++++++++++++++++++----------- contrib/perspectives/config.el | 3 +- contrib/perspectives/packages.el | 27 +++---- 3 files changed, 101 insertions(+), 60 deletions(-) diff --git a/contrib/perspectives/README.md b/contrib/perspectives/README.md index 75013ef0a..2ba3d2983 100644 --- a/contrib/perspectives/README.md +++ b/contrib/perspectives/README.md @@ -1,19 +1,48 @@ -# Perspectives +# Perspectives contribution layer for Spacemacs + + +**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) + + + +## Description 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. -## Custom Perspective Macro +## Install + +### Layer + +To use this contribution add it to your `~/.spacemacs` + +```elisp +(setq-default dotspacemacs-configuration-layers '(perspectives)) +``` + +### Custom Perspective Macro 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: ```elisp - (defun custom-persp/ () - (interactive) - (custom-persp "" - (... stuff to be done in the persp activating a major mode like twittering or whatever ...))) +(defun custom-persp/ () +(interactive) +(custom-persp "" + (... stuff to be done in the persp activating a major mode like twittering or whatever ...))) ``` You can check out the layer's packages.el to see some examples of the @@ -21,36 +50,41 @@ custom-perspectives. if you define something like this you may be able to define a perspective with a layout. ```elisp - (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 ...) - ))) +(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 ...) + ))) ``` Then you just need to add a keybinding to your custom persp, we use -` P o [your key here]` (Perspective open ) - -``` elisp - (evil-leader/set-key "Po" 'custom-persp/)) -``` - - -## Keybindings - -Perspective-mode defines keybindings under `C-x x` so we will take a more -`spacemacsy` approach and define them under out perspective map ` P` +SPC L o [your key here] (Perspective open ) ```elisp - (projectile-persp-bridge helm-projectile) - (setq projectile-switch-project-action 'helm-projectile) +(evil-leader/set-key "Lo" 'custom-persp/)) ``` -### org-agenda ` P o o` (Perspective Open Org) +## Predefined custom perspectives + +#### Per project custom perpsective + +As the name suggests, this persp-projectile mode creates a new perspective +once you switch to a new project with ` 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. + +If you are a helm person, and would rather use helm for projectile add this to +your config as well: + +```elisp +(projectile-persp-bridge helm-projectile) +``` + +#### Org-agenda custom perspective Here we define a custom perspective that adds items to your org-agenda if you do not know what that is check the @@ -61,22 +95,7 @@ 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`) -## Persp-Projectile - -As the name suggests, this persp-projectile mode creates a new perspective -once you switch to a new project with ` 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 P o e` to go to the init.el in the spacemacs. - -If you are a helm person, and would rather use helm for projectile add this to -your config as well: - -```elisp -(projectile-persp-bridge helm-projectile) -(setq projectile-switch-project-action 'helm-projectile) -``` - -## RCIRC +#### RCIRC custom perspective Now you can also open rcirc in a new layer to keep all the chat buffers in one perspective isolated from your work buffers. @@ -87,3 +106,25 @@ You will have to use the perspective layer as well as the rcirc layer: (setq-default dotspacemacs-configuration-layers '(rcirc perspectives)) ``` + +## Key Bindings + +Prefix command for perspective commands is SPC L (for Layout). + +Key Binding | Description +----------------------|------------------------------------------------ +SPC L A | Add current buffer to the current perspective +SPC L c | Close a perspective (kill it) +SPC L k | Remove current buffer from the current perspective +SPC L n | Next perspective +SPC L p | Previous perspective +SPC L r | Rename current perspective +SPC L s | Switch to a perspective + +### Custom Perspectives Key Bindings + +Key Binding | Description +----------------------|------------------------------------------------ +SPC L o e | Emacs custom perspective +SPC L o i | RCIRC custom perspective +SPC L o o | Org custom perspective diff --git a/contrib/perspectives/config.el b/contrib/perspectives/config.el index e72a1561a..0c425e111 100644 --- a/contrib/perspectives/config.el +++ b/contrib/perspectives/config.el @@ -6,4 +6,5 @@ ;; Variables (defvar perspective-enable-persp-projectile nil - "If non nil the helm-projectile-swtich-project command will create a new perspective for each new project.") + "If non nil the helm-projectile-swtich-project command will create +a new perspective for each new project.") diff --git a/contrib/perspectives/packages.el b/contrib/perspectives/packages.el index 8dee5ebd4..7d27f8803 100644 --- a/contrib/perspectives/packages.el +++ b/contrib/perspectives/packages.el @@ -38,22 +38,21 @@ which require an initialization must be listed explicitly in the list.") (defun custom-persp/rcirc () (interactive) (custom-persp "@RCIRC" (rcirc-config))) - (evil-leader/set-key - "Poi" 'custom-persp/rcirc) - (spacemacs/declare-prefix "P" "perspectives") - (spacemacs/declare-prefix "Po" "custom-perspectives") + (spacemacs/declare-prefix "L" "layouts") + (spacemacs/declare-prefix "Lo" "custom-perspectives") (evil-leader/set-key - "Pa" 'persp-add-buffer - "PA" 'persp-set-buffer - "Pc" 'persp-kill - "Pk" 'persp-remove-buffer - "Pn" 'persp-next - "Poe" 'custom-persp/emacs - "Poo" 'custom-persp/org - "Pp" 'persp-prev - "Pr" 'persp-rename - "Ps" 'persp-switch)) + "La" 'persp-add-buffer + "LA" 'persp-set-buffer + "Lc" 'persp-kill + "Lk" 'persp-remove-buffer + "Ln" 'persp-next + "Loe" 'custom-persp/emacs + "Loi" 'custom-persp/rcirc + "Loo" 'custom-persp/org + "Lp" 'persp-prev + "Lr" 'persp-rename + "Ls" 'persp-switch)) :config (progn (persp-mode t)