2022-03-28 15:03:21 +02:00
#+title : :app irc
#+subtitle : How neckbeards socialize
#+created : June 11, 2017
#+since : 2.0.3
2021-10-16 01:20:46 +02:00
* Description :unfold:
2019-12-27 00:17:18 -05:00
This module turns Emacs into an IRC client, capable of OS notifications.
2019-01-05 16:30:00 -05:00
2021-10-16 01:20:46 +02:00
** Maintainers
/This module has no dedicated maintainers./ [[doom-contrib-maintainer: ][Become a maintainer? ]]
2019-01-05 16:30:00 -05:00
2021-10-16 01:20:46 +02:00
** Module flags
/This module has no flags./
2017-08-21 20:07:07 +02:00
2021-10-16 01:20:46 +02:00
** Packages
2022-09-26 02:19:42 +08:00
- [[doom-package:circe ]]
- [[doom-package:circe-notifications ]]
2021-10-16 01:20:46 +02:00
** Hacks
/No hacks documented for this module./
** TODO Changelog
# This section will be machine generated. Don't edit it by hand.
/This module does not have a changelog yet./
* Installation
[[id:01cffea4-3329-45e2-a892-95a384ab2338 ][Enable this module in your ~doom!~ block. ]]
This module requires:
- [[https://www.gnutls.org/ ][GnuTLS ]], for secure IRC connections to work.
This should be available through your OS package manager.
2019-12-27 00:17:18 -05:00
** macOS
2021-10-16 01:20:46 +02:00
#+begin_src sh
2019-12-27 00:17:18 -05:00
brew install gnutls
2021-10-16 01:20:46 +02:00
#+end_src
2019-12-27 00:17:18 -05:00
** Debian / Ubuntu
2021-10-16 01:20:46 +02:00
#+begin_src sh
2019-12-27 00:17:18 -05:00
apt install gnutls-bin
2021-10-16 01:20:46 +02:00
#+end_src
2019-12-27 00:17:18 -05:00
** Arch Linux
2021-10-16 01:20:46 +02:00
#+begin_src sh
2019-12-27 00:17:18 -05:00
pacman -S gnutls
2021-10-16 01:20:46 +02:00
#+end_src
2019-12-27 00:17:18 -05:00
** NixOS
2021-10-16 01:20:46 +02:00
#+begin_src nix
2019-12-27 00:17:18 -05:00
environment.systemPackages = [ pkgs.gnutls ];
2021-10-16 01:20:46 +02:00
#+end_src
* TODO Usage
#+begin_quote
🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module: ][Complete it? ]]
#+end_quote
To connect to IRC use ~M-x =irc~ .
When in a circe buffer these keybindings will be available:
| command | key | description |
|-----------------------------+-----------------+----------------------------------------------|
| ~+irc/tracking-next-buffer~ | [[kbd:][<localleader> a]] | Switch to the next active buffer |
| ~circe-command-JOIN~ | [[kbd:][<localleader> j]] | Join a channel |
| ~+irc/send-message~ | [[kbd:][<localleader> m]] | Send a private message |
| ~circe-command-NAMES~ | [[kbd:][<localleader> n]] | List the names of the current channel |
| ~circe-command-PART~ | [[kbd:][<localleader> p]] | Part the current channel |
| ~+irc/quit~ | [[kbd:][<localleader> Q]] | Kill the current circe session and workgroup |
| ~circe-reconnect~ | [[kbd:][<localleader> R]] | Reconnect the current server |
* TODO Configuration
#+begin_quote
🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module: ][Complete it? ]]
#+end_quote
Use ~set-irc-server! SERVER PLIST~ to configure IRC servers. Its second argument
(a plist) takes the same arguments as ~circe-network-options~ :
#+begin_src emacs-lisp
2019-12-27 00:17:18 -05:00
;; if you omit =:host= , ~SERVER~ will be used instead.
(after! circe
2021-05-29 00:21:39 -07:00
(set-irc-server! "irc.libera.chat"
2019-12-27 00:17:18 -05:00
`(:tls t
:port 6697
:nick "doom"
:sasl-username "myusername"
:sasl-password "mypassword"
:channels ("#emacs"))))
2021-10-16 01:20:46 +02:00
#+end_src
2017-06-12 12:37:38 +02:00
2019-12-27 00:17:18 -05:00
However, *it is a obviously a bad idea to store your password in plaintext,* so
here are ways to avoid that:
2017-06-12 12:37:38 +02:00
2021-10-16 01:20:46 +02:00
** TODO Pass: the unix password manager
#+begin_quote
🔨 /This section is outdated and needs to be rewritten./ [[doom-contrib-module: ][Rewrite it? ]]
#+end_quote
2019-01-05 16:30:00 -05:00
[[https://www.passwordstore.org/ ][Pass ]] is my tool of choice. I use it to manage my passwords. If you activate the
2022-09-26 02:19:42 +08:00
[[doom-module::tools pass ]] module you get an elisp API through which to access your password
2021-10-16 01:20:46 +02:00
store.
2017-06-12 12:37:38 +02:00
2019-01-05 16:30:00 -05:00
~set-irc-server!~ accepts a plist can use functions instead of strings.
~+pass-get-user~ and ~+pass-get-secret~ can help here:
2021-10-16 01:20:46 +02:00
#+begin_src emacs-lisp
2021-05-29 00:21:39 -07:00
(set-irc-server! "irc.libera.chat"
2019-01-05 16:30:00 -05:00
`(:tls t
2019-12-27 00:17:18 -05:00
:port 6697
2019-01-05 16:30:00 -05:00
:nick "doom"
2021-05-29 00:21:39 -07:00
:sasl-username ,(+pass-get-user "irc/libera.chat")
:sasl-password ,(+pass-get-secret "irc/libera.chat")
2019-01-05 16:30:00 -05:00
:channels ("#emacs")))
2021-10-16 01:20:46 +02:00
#+end_src
2017-06-12 12:37:38 +02:00
2019-01-05 16:30:00 -05:00
But wait, there's more! This stores your password in a public variable which
could be accessed or appear in backtraces. Not good! So we go a step further:
2021-10-16 01:20:46 +02:00
#+begin_src emacs-lisp
2021-05-29 00:21:39 -07:00
(set-irc-server! "irc.libera.chat"
2019-01-05 16:30:00 -05:00
`(:tls t
2019-02-20 13:14:14 +05:30
:port 6697
2019-01-05 16:30:00 -05:00
:nick "doom"
2021-05-29 00:21:39 -07:00
:sasl-username ,(+pass-get-user "irc/libera.chat")
:sasl-password (lambda (&rest _) (+pass-get-secret "irc/libera.chat"))
2019-01-05 16:30:00 -05:00
:channels ("#emacs")))
2021-10-16 01:20:46 +02:00
#+end_src
2017-06-12 12:37:38 +02:00
And you're good to go!
2021-10-16 01:20:46 +02:00
Note that ~+pass-get-user~ tries to find your username by looking for the fields
listed in ~+pass-user-fields~ (by default =login= , =user= =, =username= = and
2019-01-05 16:30:00 -05:00
=email= )=). An example configuration looks like
2018-06-23 15:28:27 +02:00
2019-12-27 00:17:18 -05:00
#+begin_example
2018-06-23 15:28:27 +02:00
mysecretpassword
username: myusername
2019-12-27 00:17:18 -05:00
#+end_example
2018-06-23 15:28:27 +02:00
2017-08-21 20:07:07 +02:00
** Emacs' auth-source API
2019-01-05 16:30:00 -05:00
~auth-source~ is built into Emacs. As suggested [[https://github.com/jorgenschaefer/circe/wiki/Configuration#safer-password-management ][in the circe wiki ]], you can store
(and retrieve) encrypted passwords with it.
2021-10-16 01:20:46 +02:00
#+begin_src emacs-lisp
2017-06-12 12:37:38 +02:00
(setq auth-sources '("~/.authinfo.gpg"))
(defun my-fetch-password (&rest params)
(require 'auth-source)
(let ((match (car (apply #'auth-source-search params))))
(if match
(let ((secret (plist-get match :secret)))
(if (functionp secret)
(funcall secret)
secret))
(error "Password not found for %S" params))))
(defun my-nickserv-password (server)
2021-05-29 00:21:39 -07:00
(my-fetch-password :user "forcer" :host "irc.libera.chat"))
2017-06-12 12:37:38 +02:00
2021-05-29 00:21:39 -07:00
(set-irc-server! "irc.libera.chat"
2019-01-05 16:30:00 -05:00
'(:tls t
2019-02-20 13:14:14 +05:30
:port 6697
2019-01-05 16:30:00 -05:00
:nick "doom"
:sasl-password my-nickserver-password
:channels ("#emacs")))
2021-10-16 01:20:46 +02:00
#+end_src
2017-06-11 01:49:39 +02:00
2019-01-05 16:30:00 -05:00
* TODO Troubleshooting
2021-10-16 01:20:46 +02:00
/There are no known problems with this module./ [[doom-report: ][Report one? ]]
* Frequently asked questions
/This module has no FAQs yet./ [[doom-suggest-faq: ][Ask one? ]]
* TODO Appendix
#+begin_quote
🔨 This module has no appendix yet. [[doom-contrib-module: ][Write one? ]]
#+end_quote