app/irc: general rewrite (#103)
+ Refactor initialization process. + Refactor for consistency. + Add +irc-defer-notifications (for ZNC users). + Rewrote =irc (opens separate workspace + auto-connects to registered networks). + Add +irc/connect (connect to specific network). + Add +irc/quit (kill whole circe session). + Add +irc/ivy-jump-to-channel command. + Rewrite README. + Silence QUIT/PART default messages; they're cute, but no thanks. + Truncate nicks non-destructively. + Jump to prompt when entering insert mode (with evil). + Activate solaire-mde in channel buffers to visually distinguish them from server buffers.
This commit is contained in:
parent
07299c5020
commit
b3dafe96d3
3 changed files with 201 additions and 90 deletions
|
@ -1,19 +1,74 @@
|
|||
* :app irc
|
||||
|
||||
This module makes Emacs an irc client, using [[https://github.com/jorgenschaefer/circe][~circe~]].
|
||||
This module turns adds an IRC client to Emacs ([[https://github.com/jorgenschaefer/circe][~circe~)]] with native notifications ([[https://github.com/eqyiel/circe-notifications][circe-notifications]]).
|
||||
|
||||
** Dependencies
|
||||
This module has no dependencies, besides =gnutls-cli= or =openssl= for secure connections.
|
||||
|
||||
I use ~pass~ to not have the passwords written in my dotfiles. It's available under ~:tools~ modules.
|
||||
If you want to use TLS you also need =openssl= or =gnutls-cli=.
|
||||
** Configure
|
||||
Use the ~:irc~ setting to configure IRC servers. Its second argument (a plist) takes the same arguments as ~circe-network-options~.
|
||||
|
||||
Configure Emacs to use your favorite irc servers:
|
||||
#+BEGIN_SRC emacs-lisp :tangle no
|
||||
(set! :irc "chat.freenode.net"
|
||||
`(:tls t
|
||||
:nick "benny"
|
||||
:sasl-username ,(password-store-get "irc/freenode")
|
||||
:sasl-password ,(password-store-get "irc/freenode")
|
||||
:nick "doom"
|
||||
:sasl-username "myusername"
|
||||
:sasl-password "mypassword"
|
||||
:channels ("#emacs")))
|
||||
#+END_SRC
|
||||
|
||||
*It is a obviously a bad idea to store auth-details in plaintext,* so here are some ways to avoid that:
|
||||
|
||||
*** Pass: the unix password manager
|
||||
[[https://www.passwordstore.org/][Pass]] is my tool of choice. I use it to manage my passwords. If you activate the [[/modules/tools/password-store/README.org][:tools password-store]] module you get an elisp API through which to access your password store.
|
||||
|
||||
~:irc~'s plist can use functions instead of strings. ~+pass-get-user~ and ~+pass-get-secret~ can help here:
|
||||
|
||||
#+BEGIN_SRC emacs-lisp :tangle no
|
||||
(set! :irc "chat.freenode.net"
|
||||
`(:tls t
|
||||
:nick "doom"
|
||||
:sasl-username ,(+pass-get-user "irc/freenode.net")
|
||||
:sasl-password ,(+pass-get-secret "irc/freenode.net")
|
||||
:channels ("#emacs")))
|
||||
#+END_SRC
|
||||
|
||||
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:
|
||||
|
||||
#+BEGIN_SRC emacs-lisp :tangle no
|
||||
(set! :irc "chat.freenode.net"
|
||||
`(:tls t
|
||||
:nick "doom"
|
||||
:sasl-username ,(+pass-get-user "irc/freenode.net")
|
||||
:sasl-password (lambda (&rest _) (+pass-get-secret "irc/freenode.net"))
|
||||
:channels ("#emacs")))
|
||||
#+END_SRC
|
||||
|
||||
And you're good to go!
|
||||
|
||||
*** Emacs' auth-source API
|
||||
~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.
|
||||
|
||||
#+BEGIN_SRC emacs-lisp :tangle no
|
||||
(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)
|
||||
(my-fetch-password :user "forcer" :host "irc.freenode.net"))
|
||||
|
||||
(set! :irc "chat.freenode.net"
|
||||
'(:tls t
|
||||
:nick "doom"
|
||||
:sasl-password my-nickserver-password
|
||||
:channels ("#emacs")))
|
||||
#+END_SRC
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue