doomemacs/modules/app/irc
Henrik Lissner 4daa9271a0
Introduce general.el & rewrite map!
+ Now uses an overriding keymap for leader keys, so that it is always
  available, even outside of normal/visual states. In insert/emacs
  states, or in sessions where evil is absent, an alternative prefix is
  used for leader/localleader keys. See these variables:
  + doom-leader-prefix
  + doom-leader-alt-prefix
  + doom-localleader-prefix
  + doom-localleader-alt-prefix
+ Keybinds now support alternative prefixes through the new :alt-prefix
  property. This is useful for non-evil users and non-normal evil
  states. By default, this is M-SPC (leader) and M-SPC m (localleader).
+ Removed +evil-commands flag from config/default (moved to
  feature/evil/+commands.el).
+ config/default/+bindings.el has been split into
  config/default/+{evil,emacs}-bindings.el, which one is loaded depends
  on whether evil is present or not. The latter is blank, but will soon
  be populated with a keybinding scheme for non-evil users (perhaps
  inspired by #641).
+ The define-key! macro has been replaced; it is now an alias for
  general-def.
+ Added unmap! as an alias for general-unbind.
+ The following modifier key conventions are now enforced for
  consistency, across all OSes:
    alt/option      = meta
    windows/command = super
  It used to be
    alt/option      = alt
    windows/command = meta
  Many of the default keybinds have been updated to reflect this switch,
  but it is likely to affect personal meta/super keybinds!

The map! macro has also been rewritten to use general-define-key. Here
is what has been changed:

+ map! no longer works with characters, e.g. (map! ?x #'do-something) is
  no longer supported. Keys must be kbd-able strings like "C-c x" or
  vectors like [?C-c ?x].
+ The :map and :map* properties are now the same thing. If specified
  keymaps aren't defined when binding keys, it is automatically
  deferred.
+ The way you bind local keybinds has changed:

    ;; Don't do this
    (map! :l "a" #'func-a
          :l "b" #'func-b)
    ;; Do this
    (map! :map 'local "a" #'func-a
                      "b" #'func-b)

+ map! now supports the following new blocks:
  + (:if COND THEN-FORM ELSE-FORM...)
  + (:alt-prefix PREFIX KEYS...) -- this prefix will be used for
    non-normal evil states. Equivalent to :non-normal-prefix in general.
+ The way you declare a which-key label for a prefix key has changed:

    ;; before
    (map! :desc "label" :prefix "a" ...)
    ;; now
    (map! :prefix ("a" . "label") ...)

+ It used to be that map! supported binding a key to a key sequence,
  like so:

    (map! "a" [?x])  ; pressing a is like pressing x

  This functionality was removed *temporarily* while I figure out the
  implementation.

Addresses: #448, #814, #860
Mentioned in: #940
2018-12-22 04:14:43 -05:00
..
autoload Add set-irc-server! autodef & move :irc setting 2018-06-24 22:23:08 +02:00
config.el Introduce general.el & rewrite map! 2018-12-22 04:14:43 -05:00
packages.el app/irc: initial commit 2017-06-11 15:55:22 +02:00
README.org Remove the SPC o I keybinding to open IRC 2018-06-24 00:01:07 +02:00

:app irc

This module turns adds an IRC client to Emacs (circe) with native notifications (circe-notifications).

Table of Contents   TOC

Dependencies

This module has no dependencies, besides gnutls-cli or openssl for secure connections.

Configure

Use the :irc setting to configure IRC servers. Its second argument (a plist) takes the same arguments as circe-network-options.

(set! :irc "chat.freenode.net"
    `(:tls t
      :nick "doom"
      :sasl-username "myusername"
      :sasl-password "mypassword"
      :channels ("#emacs")))

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

Pass is my tool of choice. I use it to manage my passwords. If you activate the :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:

(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")))

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:

(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")))

And you're good to go!

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 email)=). An example configuration looks like

mysecretpassword
username: myusername

Emacs' auth-source API

auth-source is built into Emacs. As suggested in the circe wiki, you can store (and retrieve) encrypted passwords with it.

(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")))

Appendix

Commands

To connect to IRC you can invoke the =irc function using M-x or your own custom keybinding.

command description
=irc Connect to IRC and all configured servers

When in a circe buffer these keybindings will be available.

command key description
tracking-next-buffer SPC m a Switch to the next active buffer
circe-command-JOIN SPC m j Join a channel
+irc/send-message SPC m m Send a private message
circe-command-NAMES SPC m n List the names of the current channel
circe-command-PART SPC m p Part the current channel
+irc/quit SPC m Q Kill the current circe session and workgroup
circe-reconnect SPC m R Reconnect the current server