hamacs/ha-irc.org
Howard Abrams 4a5f426428 Meta-Space for Global Leader, and Shift-Space for Local
Let's see if this really works for insert mode.
2021-12-14 11:42:26 -08:00

136 lines
4.4 KiB
Org Mode

#+TITLE: IRC and Bitlbee Interface
#+AUTHOR: Howard X. Abrams
#+DATE: 2020-12-10
#+FILETAGS: :emacs:
A literate programming configuration file for IRC communiction.
#+BEGIN_SRC emacs-lisp :exports none
;;; ha-irc.el --- configuration for IRC communication. -*- lexical-binding: t; -*-
;;
;; Copyright (C) 2020 Howard X. Abrams
;;
;; Author: Howard X. Abrams <http://gitlab.com/howardabrams>
;; Maintainer: Howard X. Abrams
;; Created: December 10, 2020
;;
;; This file is not part of GNU Emacs.
;;
;; *NB:* Do not edit this file. Instead, edit the original literate file at:
;; ~/other/hamacs/ha-irc.org
;; And tangle the file to recreate this one.
;;
;;; Code:
#+END_SRC
* Introduction
My IRC /needs/ are basic, but I'm not sure which I want to use.
** Circe
The [[https://github.com/emacs-circe/circe][circe project]] (see the [[http://www.nongnu.org/circe/][old site]]) looks intriguing, and is still supported. See the [[https://github.com/emacs-circe/circe/wiki][wiki documentation]], but it has good defaults.
#+BEGIN_SRC emacs-lisp
(use-package circe
:init
(setq circe-reduce-lurker-spam t
lui-flyspell-p t
circe-network-options
'(("howardabrams.com"
:tls nil
:nick "howard-abrams"
:port 7777
:sasl-username "howard-abrams")))
:config
;; Trick to ignore the PART and QUIT messages:
(circe-set-display-handler "PART" (lambda (&rest ignored) nil))
(circe-set-display-handler "QUIT" (lambda (&rest ignored) nil)))
#+END_SRC
* ZNC Server
I'm using my own ZNC server, and I need to log in with a password stored in my GPG auth storage:
#+BEGIN_SRC emacs-lisp
(defun ha-circe-reconnect-password ()
"Send the reconnection password string."
(interactive)
(let* ((auth-results (auth-source-search :host "howardabrams.com" :port 7777 :max 1))
(auth-first (first auth-results))
(username (plist-get auth-first :user))
(password (funcall (plist-get auth-first :secret))))
(circe-command-QUOTE (format "PASS %s:%s" username password))))
#+END_SRC
But now we can call both the reconnect, as well as the password:
#+BEGIN_SRC emacs-lisp
(defun ha-circe-reconnect ()
"Overlay interface to reconnect to my IRC server."
(interactive)
(circe-reconnect)
(sit-for 3)
(ha-circe-reconnect-password))
#+END_SRC
* Key Bindings
Quick way to start and jump to my IRC world.
#+BEGIN_SRC emacs-lisp
(defun ha-irc-persp-start ()
"Create an IRC workspace and start my IRC client."
(interactive)
(persp-switch "irc")
(circe "howardabrams.com"))
(defun ha-irc-persp-switch ()
"Switch to the IRC workspace and load the next buffer."
(interactive)
(persp-switch "irc")
(tracking-next-buffer))
#+END_SRC
And some global keys to display them:
#+BEGIN_SRC emacs-lisp
(ha-leader
"a i" '("irc switch" . ha-irc-persp-switch)
"a I" '("irc start" . ha-irc-persp-start))
#+END_SRC
Let's create a leader for this mode:
#+BEGIN_SRC emacs-lisp
(general-create-definer ha-circe-leader
:states '(normal visual motion)
:keymaps '(circe-channel-mode-map circe-server-mode-map)
:prefix "SPC m"
:global-prefix "<f17>"
:non-normal-prefix "S-SPC")
#+END_SRC
And a quick shortcut to call it:
#+BEGIN_SRC emacs-lisp
(ha-circe-leader
"o" '("next channel" . tracking-next-buffer)
"r" '("reconnect" . ha-circe-reconnect)
"p" '("send password" . ha-circe-reconnect-password))
#+END_SRC
* Display Configuration
Using the [[https://github.com/seagle0128/doom-modeline][Doom Modeline]] to add notifications:
#+BEGIN_SRC emacs-lisp
(setq doom-modeline-irc t)
(setq doom-modeline-irc-stylize 'identity)
#+END_SRC
* Technical Artifacts :noexport:
This will =provide= a code name, so that we can =require= this.
#+BEGIN_SRC emacs-lisp :exports none
(provide 'ha-irc)
;;; ha-irc.el ends here
#+END_SRC
#+DESCRIPTION: A literate programming configuration file for IRC.
#+PROPERTY: header-args:sh :tangle no
#+PROPERTY: header-args:emacs-lisp :tangle yes
#+PROPERTY: header-args :results none :eval no-export :comments no mkdirp yes
#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil date:nil
#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil
#+INFOJS_OPT: view:nil toc:nil ltoc:t mouse:underline buttons:0 path:http://orgmode.org/org-info.js