Skip to content

Commit

Permalink
Add IRC buffers to respective perspectives
Browse files Browse the repository at this point in the history
This attempts to fix syl20bnr#4781
  • Loading branch information
CestDiego committed Jan 31, 2016
1 parent f386cbc commit a1fc67b
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 26 deletions.
6 changes: 6 additions & 0 deletions layers/+irc/erc/README.org
Original file line number Diff line number Diff line change
Expand Up @@ -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]].
Expand Down Expand Up @@ -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~
6 changes: 6 additions & 0 deletions layers/+irc/erc/config.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)
25 changes: 15 additions & 10 deletions layers/+irc/erc/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -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))
7 changes: 7 additions & 0 deletions layers/+irc/rcirc/README.org
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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~
6 changes: 6 additions & 0 deletions layers/+irc/rcirc/config.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)
25 changes: 15 additions & 10 deletions layers/+irc/rcirc/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions layers/+window-management/spacemacs-layouts/README.org
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit a1fc67b

Please sign in to comment.