From 7aa9a0c647faff04c33c4934b290a2d6f7c6d64e Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Thu, 14 Oct 2021 20:40:44 -0500 Subject: Move most of acdw-irc to acdw-circe --- lisp/acdw-circe.el | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'lisp/acdw-circe.el') diff --git a/lisp/acdw-circe.el b/lisp/acdw-circe.el index 076bbc6..4ff3fdf 100644 --- a/lisp/acdw-circe.el +++ b/lisp/acdw-circe.el @@ -7,9 +7,32 @@ ;;; Code: (require 'circe) +(require 'el-patch) ;;; Functions +(defun irc () + "Connect to all IRC networks in `circe-network-options'." + (interactive) + (dolist (network (mapcar #'car circe-network-options)) + (unless (member network circe-network-inhibit-autoconnect) + (circe-maybe-connect network)))) + +(defun circe-network-connected-p (network) + "Return whether circe is connected to NETWORK." + (catch 'return + (dolist (buffer (circe-server-buffers)) + (with-current-buffer buffer + (if (string= network circe-server-network) + (throw 'return t)))))) + +(defun circe-maybe-connect (network) + "Connect to NETWORK, asking for confirmation to reconnect." + (interactive "sNetwork: ") + (if (or (not (circe-network-connected-p network)) + (y-or-n-p (format "Already connected to %s, reconnect? " network))) + (circe network))) + (defun circe-current-topic (&optional message) "Return the topic of the current channel. When called with MESSAGE set to non-nil (or interactively), also @@ -93,6 +116,43 @@ message the current topic." (message "%s: %s" buf circe-server-killed-confirmation) (kill-buffer))))) +;;; Patches + +(el-patch-feature circe) +(with-eval-after-load 'circe + (defvar circe-server-buffer-action 'pop-to-buffer-same-window + "What to do with `circe-server' buffers when created.") + + (el-patch-defun circe (network-or-server &rest server-options) + "Connect to IRC. + +Connect to the given network specified by NETWORK-OR-SERVER. + +When this function is called, it collects options from the +SERVER-OPTIONS argument, the user variable +`circe-network-options', and the defaults found in +`circe-network-defaults', in this order. + +If NETWORK-OR-SERVER is not found in any of these variables, the +argument is assumed to be the host name for the server, and all +relevant settings must be passed via SERVER-OPTIONS. + +All SERVER-OPTIONS are treated as variables by getting the string +\"circe-\" prepended to their name. This variable is then set +locally in the server buffer. + +See `circe-network-options' for a list of common options." + (interactive (circe--read-network-and-options)) + (let* ((options (circe--server-get-network-options network-or-server + server-options)) + (buffer (circe--server-generate-buffer options))) + (with-current-buffer buffer + (circe-server-mode) + (circe--server-set-variables options) + (circe-reconnect)) + (el-patch-swap (pop-to-buffer-same-window buffer) + (funcall circe-server-buffer-action buffer))))) + ;;; Dumb modes (define-minor-mode circe-cappy-hour-mode -- cgit 1.4.1-21-gabe81