From 57e0cf321acddd1326e8abba9d8f0cd6fd3d474f Mon Sep 17 00:00:00 2001 From: Koustubh Sinkar Date: Sun, 13 Aug 2017 21:26:37 +0530 Subject: [PATCH] Make it possible to auto-create a new perspective for IRC (#1097) --- modules/doc/prelude-erc.md | 45 +++++++++++++++++++++++++++----------- modules/prelude-erc.el | 18 ++++++++++++--- 2 files changed, 47 insertions(+), 16 deletions(-) diff --git a/modules/doc/prelude-erc.md b/modules/doc/prelude-erc.md index 539c725..5f61069 100644 --- a/modules/doc/prelude-erc.md +++ b/modules/doc/prelude-erc.md @@ -2,30 +2,49 @@ ## Customizing Server list -If you want to join a list of servers on `M-x start-irc`, other than the default list, please redefine the variable `my-fav-irc` as follows in your personal config +If you want to join a list of servers on `M-x start-irc`, other than +the default list, please redefine the variable `my-fav-irc` as follows +in your personal config -``` emacs-lisp -(setq my-fav-irc '( "irc.freenode.net" - "irc.oftc.net" - "irc.mozilla.org" - "irc.gnome.org")) +``` emacs-lisp +(setq my-fav-irc '("irc.freenode.net" + "irc.oftc.net" + "irc.mozilla.org" + "irc.gnome.org")) ``` ## Customizing Last Quit Message -If you want to customize your IRC Last Quit Message from *Asta la vista* to something more funkier, please redefine `bye-irc-message` as follows +If you want to customize your IRC Last Quit Message from *Asta la +vista* to something more funkier, please redefine `bye-irc-message` as +follows -``` emacs-lisp -(setq bye-erc-message "adios") +``` emacs-lisp +(setq bye-erc-message "adios") ``` ## Reading NickServ passwords from auth-source plugin -If you want to automatically authenticate while logging into IRC servers set the `erc-prompt-for-password` to nil as follows +If you want to automatically authenticate while logging into IRC +servers set the `erc-prompt-for-password` to nil as follows -``` emacs-lisp -(setq erc-prompt-for-password nil) +``` emacs-lisp +(setq erc-prompt-for-password nil) ``` -Now you can set password in plaintext in .authinfo file in the netRC format or you it encrypted in .authinfo.gpg file after setting up gpg in emacs +Now you can set password in plaintext in .authinfo file in the netRC +format or you it encrypted in .authinfo.gpg file after setting up gpg +in emacs +## Opening all ERC buffers in a new perspective +Many a time when we start IRC with the `start-irc` command, all the +channels open in our existing workspace, which can be annoying to +some; especially to those who like to organize their buffers into +separate groups (perspectives). To avoid this scenario, it is better +to group all the ERC buffers into one perspective called `IRC` when +`start-irc` is called. To enable this set the `prelude-new-irc-persp` +variable to true as follows + +``` emacs-lisp +(setq prelude-new-irc-persp t) +``` diff --git a/modules/prelude-erc.el b/modules/prelude-erc.el index fb5f2c9..701009c 100644 --- a/modules/prelude-erc.el +++ b/modules/prelude-erc.el @@ -114,10 +114,16 @@ that can occur between two notifications. The default is (defvar my-fav-irc '( "irc.freenode.net" ) - "Stores the list of IRC servers that you want to connect to with start-irc.") + "Stores the list of IRC servers that you want to connect to with start-irc.") (defvar bye-irc-message "Asta la vista" - "Message string to be sent while quitting IRC.") + "Message string to be sent while quitting IRC.") + +(defcustom prelude-new-irc-persp nil + "True (t) means start IRC in new perspective." + :type 'boolean + :require 'prelude-erc + :group 'prelude) (defun connect-to-erc (server) "Connects securely to IRC SERVER over TLS at port 6697." @@ -129,6 +135,8 @@ that can occur between two notifications. The default is "Connect to IRC?" (interactive) (when (y-or-n-p "Do you want to start IRC? ") + (when prelude-new-irc-persp + (persp-switch "IRC")) (mapcar 'connect-to-erc my-fav-irc))) (defun filter-server-buffers () @@ -140,10 +148,14 @@ that can occur between two notifications. The default is (defun stop-irc () "Disconnects from all irc servers." (interactive) + (when prelude-new-irc-persp + (persp-switch "IRC")) (dolist (buffer (filter-server-buffers)) (message "Server buffer: %s" (buffer-name buffer)) (with-current-buffer buffer - (erc-quit-server bye-irc-message)))) + (erc-quit-server bye-irc-message))) + (when prelude-new-irc-persp + (persp-kill "IRC"))) (provide 'prelude-erc)