hamacs/ha-irc.org

152 lines
5.1 KiB
Org Mode
Raw Normal View History

2021-11-24 00:42:00 +00:00
#+TITLE: IRC and Bitlbee Interface
#+AUTHOR: Howard X. Abrams
#+DATE: 2020-12-10
A literate programming configuration file for IRC communiction.
#+begin_src emacs-lisp :exports none
;;; ha-irc.el --- configuration for IRC communication. -*- lexical-binding: t; -*-
;;
;; © 2020-2023 Howard X. Abrams
;; Licensed under a Creative Commons Attribution 4.0 International License.
;; See http://creativecommons.org/licenses/by/4.0/
;;
;; 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
2021-11-24 00:42:00 +00:00
* Introduction
My IRC /needs/ are basic, but I'm not sure which I want to use.
** ERC
#+begin_src emacs-lisp
(use-package erc-hl-nicks
:after erc)
(use-package erc-image
:after erc)
(use-package erc
:commands erc
:config
(setq
erc-nick "howard-abrams"
erc-user-full-name "Howard Abrams"
erc-prompt ">>"
erc-prompt-for-nickserv-password nil
erc-auto-query 'bury
erc-join-buffer 'bury
erc-interpret-mirc-color t
erc-rename-buffers t
erc-hide-list '("JOIN" "PART" "QUIT")
erc-track-enable-keybindings nil
erc-track-visibility nil ; Only use the selected frame for visibility
erc-fill-column 120
erc-fill-function 'erc-fill-static
erc-fill-static-center 20
erc-timestamp-only-if-changed-flag nil
;; erc-timestamp-format "%H:%M"
erc-autojoin-channels-alist '(("howardabrams.com" "#emacs" "#org-mode"))
erc-quit-reason (lambda (s) (or s "Fading out..."))
erc-modules
'(autoaway autojoin button completion fill irccontrols keep-place
list match menu move-to-prompt netsplit networks noncommands
readonly ring stamp track hl-nicks)))
(defun ha-erc-connect-irc ()
"Connect to my favorite IRC server with ERC."
(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))))
(erc :server "howardabrams.com" :port 7777)
(sit-for 2)
(erc-cmd-QUOTE (format "PASS %s:%s" username password))))
#+end_src
I like to make sure the text formats to the size of the window:
#+begin_src emacs-lisp
(defun ha-erc-resize-text ()
"Resize the ERC text to fill the current window."
(interactive)
(setq erc-fill-column (1- (window-width))))
#+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-erc-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))))
(erc-cmd-QUOTE (format "PASS %s:%s" username 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")
(ha-erc-connect-irc))
(defun ha-irc-persp-switch ()
"Switch to the IRC workspace and load the next buffer."
(interactive)
(persp-switch "irc")
(call-interactively 'erc-track-switch-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
And a quick shortcuts to call it:
#+begin_src emacs-lisp
(ha-local-leader :keymaps '(erc-mode-map)
"o" '("next channel" . erc-track-switch-buffer)
"w" '("resize text" . ha-erc-resize-text)
"r" '("reconnect" . ha-erc-connect-irc)
"p" '("send password" . ha-erc-reconnect-password))
#+end_src
2021-11-24 00:42:00 +00:00
* Display Configuration
Using the [[https://github.com/seagle0128/doom-modeline][Doom Modeline]] to add notifications:
#+begin_src emacs-lisp
(setq doom-modeline-irc t
doom-modeline-irc-stylize 'identity)
#+end_src
2021-11-24 00:42:00 +00:00
* Technical Artifacts :noexport:
This will =provide= a code name, so that we can =require= this.
#+begin_src emacs-lisp :exports none
2021-11-24 00:42:00 +00:00
(provide 'ha-irc)
;;; ha-irc.el ends here
#+end_src
2021-11-24 00:42:00 +00:00
#+DESCRIPTION: A literate programming configuration file for IRC.
#+PROPERTY: header-args:sh :tangle no
#+PROPERTY: header-args:emacs-lisp :tangle ~/.emacs.d/elisp/ha-irc.el
2021-11-24 00:42:00 +00:00
#+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