From a1fc67b6f8900376b2dafc8f7f10d053bc4525d7 Mon Sep 17 00:00:00 2001 From: Diego Berrocal Date: Sun, 24 Jan 2016 23:28:10 -0500 Subject: [PATCH] Add IRC buffers to respective perspectives This attempts to fix https://github.com/syl20bnr/spacemacs/issues/4781 --- layers/+irc/erc/README.org | 6 +++++ layers/+irc/erc/config.el | 6 +++++ layers/+irc/erc/packages.el | 25 +++++++++++-------- layers/+irc/rcirc/README.org | 7 ++++++ layers/+irc/rcirc/config.el | 6 +++++ layers/+irc/rcirc/packages.el | 25 +++++++++++-------- .../spacemacs-layouts/README.org | 12 ++++----- 7 files changed, 61 insertions(+), 26 deletions(-) diff --git a/layers/+irc/erc/README.org b/layers/+irc/erc/README.org index 037ab618c6c4..341e50a232bb 100644 --- a/layers/+irc/erc/README.org +++ b/layers/+irc/erc/README.org @@ -9,6 +9,7 @@ - [[OS X][OS X]] - [[Social graph][Social graph]] - [[Key bindings][Key bindings]] + - [[Spacemacs Layout Support][Spacemacs Layout Support]] * Description Layer for [[http://www.emacswiki.org/emacs/ERC][ERC IRC chat]]. @@ -62,3 +63,8 @@ notifications via the OS X Notification Center. *Note:* If you want to connect securely to an IRC server, you must run =erc-tls= command on ~SPC a i E~ instead of the =erc= command. +* Spacemacs Layout Support + +ERC buffers are added automatically to the default layout for ERC controlled by +the variable ~erc-spacemacs-layout-name~ (defaults to "@ERC") and the default +binding ("E") is controlled by ~erc-spacemacs-layout-binding~ diff --git a/layers/+irc/erc/config.el b/layers/+irc/erc/config.el index 99e0a68b6d01..0130debdf245 100644 --- a/layers/+irc/erc/config.el +++ b/layers/+irc/erc/config.el @@ -12,4 +12,10 @@ (defvar erc-enable-sasl-auth nil "If non nil then use SASL authenthication with ERC.") +(defvar erc-spacemacs-layout-name "@ERC" + "Name used in the setup for `spacemacs-layouts' micro-state") + +(defvar erc-spacemacs-layout-binding "E" + "Binding used in the setup for `spacemacs-layouts' micro-state") + (spacemacs|defvar-company-backends erc-mode) diff --git a/layers/+irc/erc/packages.el b/layers/+irc/erc/packages.el index b557e3088b3b..65a079a24150 100644 --- a/layers/+irc/erc/packages.el +++ b/layers/+irc/erc/packages.el @@ -217,18 +217,23 @@ (defun erc/init-erc-terminal-notifier ()) (defun erc/post-init-persp-mode () - (spacemacs|define-custom-layout "@ERC" - :binding "E" - :body - (progn - (add-hook 'erc-mode #'(lambda () - (persp-add-buffer (current-buffer)))) - (call-interactively 'erc))) - ;; do not save erc buffers (spacemacs|use-package-add-hook persp-mode :post-config - (push (lambda (b) (with-current-buffer b (eq major-mode 'erc-mode))) - persp-filter-save-buffers-functions))) + (progn + ;; do not save erc buffers + (push (lambda (b) (with-current-buffer b (eq major-mode 'erc-mode))) + persp-filter-save-buffers-functions) + + (spacemacs|define-custom-layout erc-spacemacs-layout-name + :binding erc-spacemacs-layout-binding + :body + (progn + (defun spacemacs-layouts/add-erc-buffer-to-persp () + (persp-add-buffer (current-buffer) + (persp-get-by-name + erc-spacemacs-layout-name))) + (add-hook 'erc-mode-hook #'spacemacs-layouts/add-erc-buffer-to-persp) + (call-interactively 'erc)))))) (defun erc/post-init-smooth-scrolling () (add-hook 'erc-mode-hook 'spacemacs//unset-scroll-margin)) diff --git a/layers/+irc/rcirc/README.org b/layers/+irc/rcirc/README.org index c2e35fc8f35a..8a28c3490493 100644 --- a/layers/+irc/rcirc/README.org +++ b/layers/+irc/rcirc/README.org @@ -19,6 +19,7 @@ - [[Note][Note]] - [[Key Bindings][Key Bindings]] - [[Rcirc documentation][Rcirc documentation]] + - [[Spacemacs Layout Support][Spacemacs Layout Support]] * Description This layer provide support for [[http://www.gnu.org/software/emacs/manual/html_mono/rcirc.html][rcirc]] with optional support for authinfo @@ -185,3 +186,9 @@ In normal state: * Rcirc documentation The rcirc documentation can be found [[http://www.gnu.org/software/emacs/manual/html_mono/rcirc.html][here]]. + +* Spacemacs Layout Support + +RCIRC buffers are added automatically to the default layout for RCIRC controlled by +the variable ~rcirc-spacemacs-layout-name~ (defaults to "@RCIRC") and the default +binding ("i") is controlled by ~rcirc-spacemacs-layout-binding~ diff --git a/layers/+irc/rcirc/config.el b/layers/+irc/rcirc/config.el index bceef2645ae9..d8549e11d835 100644 --- a/layers/+irc/rcirc/config.el +++ b/layers/+irc/rcirc/config.el @@ -17,4 +17,10 @@ (defvar rcirc-enable-znc-support nil "if non nil then znc is enabled.") +(defvar rcirc-spacemacs-layout-name "@RCIRC" + "Name used in the setup for `spacemacs-layouts' micro-state") + +(defvar rcirc-spacemacs-layout-binding "i" + "Binding used in the setup for `spacemacs-layouts' micro-state") + (spacemacs|defvar-company-backends rcirc-mode) diff --git a/layers/+irc/rcirc/packages.el b/layers/+irc/rcirc/packages.el index 3a51c6dda7ca..e9fe2eaa403e 100644 --- a/layers/+irc/rcirc/packages.el +++ b/layers/+irc/rcirc/packages.el @@ -33,18 +33,23 @@ (spacemacs/set-leader-keys "irc" 'helm-rcirc-auto-join-channels)))) (defun rcirc/post-init-persp-mode () - (spacemacs|define-custom-layout "@RCIRC" - :binding "i" - :body - (progn - (add-hook 'rcirc-mode-hook #'(lambda () - (persp-add-buffer (current-buffer)))) - (call-interactively 'spacemacs/rcirc))) - ;; do not save rcirc buffers (spacemacs|use-package-add-hook persp-mode :post-config - (push (lambda (b) (with-current-buffer b (eq major-mode 'rcirc-mode))) - persp-filter-save-buffers-functions))) + (progn + ;; do not save rcirc buffers + (push (lambda (b) (with-current-buffer b (eq major-mode 'rcirc-mode))) + persp-filter-save-buffers-functions) + + (spacemacs|define-custom-layout rcirc-spacemacs-layout-name + :binding rcirc-spacemacs-layout-binding + :body + (progn + (defun spacemacs-layouts/add-rcirc-buffer-to-persp () + (persp-add-buffer (current-buffer) + (persp-get-by-name + rcirc-spacemacs-layout-name))) + (add-hook 'rcirc-mode-hook #'spacemacs-layouts/add-rcirc-buffer-to-persp) + (call-interactively 'spacemacs/rcirc)))))) (defun rcirc/init-rcirc () (use-package rcirc diff --git a/layers/+window-management/spacemacs-layouts/README.org b/layers/+window-management/spacemacs-layouts/README.org index 4950c2b61b7f..182c4ca4fb63 100644 --- a/layers/+window-management/spacemacs-layouts/README.org +++ b/layers/+window-management/spacemacs-layouts/README.org @@ -70,12 +70,12 @@ The layouts micro-state is initiated with ~SPC l o~. Example of default custom layouts that are configured in the corresponding layers: -| Key Binding | Description | -|-------------+----------------------------------------------------------| -| ~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 | +| Key Binding | Description | +|-------------+-------------------------------------------------------------------------------------------| +| ~e~ | Emacs custom perspective | +| ~E~ | ERC custom perspective (needs the erc layer enabled - configurable, check ERC docs) | +| ~i~ | RCIRC custom perspective (needs the rcirc layer enabled - configurable, check RCIRC docs) | +| ~o~ | Org custom perspective | **Note:** You can add more custom perspectives by using the ~spacemacs|define-custom-layout~ macro explained further below.