Add IRC buffers to respective perspectives

This attempts to fix https://github.com/syl20bnr/spacemacs/issues/4781
This commit is contained in:
Diego Berrocal 2016-01-24 23:28:10 -05:00 committed by Eivind Fonn
parent 262c760fe6
commit a86a0ee1ca
7 changed files with 61 additions and 26 deletions

View File

@ -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~

View File

@ -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)

View File

@ -219,18 +219,23 @@
:if (executable-find "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))

View File

@ -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~

View File

@ -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)

View File

@ -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

View File

@ -71,12 +71,12 @@ The layouts transient-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.