From af3eb37c8e51084261f2ad4bfe1d36fffbcfaebf Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 8 Jun 2022 17:59:53 -0500 Subject: blep --- lisp/+circe.el | 52 +++++++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 23 deletions(-) (limited to 'lisp/+circe.el') diff --git a/lisp/+circe.el b/lisp/+circe.el index e8c5079..382f0ab 100644 --- a/lisp/+circe.el +++ b/lisp/+circe.el @@ -45,21 +45,27 @@ ;;; Channel information +(defvar-local +circe-current-topic "" + "Cached topic of the buffer's channel.") + (defun +circe-current-topic (&optional message) "Return the topic of the current channel. When called with optional MESSAGE non-nil, or interactively, also message the current topic." (interactive "p") (let ((topic - (save-excursion - (goto-char (point-max)) - (or (re-search-backward - (rx (group "*** " - (or "Topic" "topic" "TOPIC") - (* (not ":")) ": ") - (group (+ nonl))))) - (buffer-substring-no-properties - (match-beginning 2) (match-end 2))))) + (or (save-excursion + (goto-char (point-max)) + (and (re-search-backward + (rx (group "*** " + (or "Topic" "topic" "TOPIC") + (* (not ":")) ": ") + (group (+ nonl))) + nil t) + (buffer-substring-no-properties + (match-beginning 2) (match-end 2)))) + +circe-current-topic))) + (setq +circe-current-topic topic) (when message (message "%s" topic)) topic)) @@ -86,8 +92,8 @@ replace {nick} in the string with {NO-NICK}." "Make a formatting regex for CHAR delimiters. For entry into `lui-formatting-list'." `(rx (or bol whitespace) - (group ,char (+? (not (any whitespace ,char))) ,char) - (or eol whitespace))) + (group ,char (+? (not (any whitespace ,char))) ,char) + (or eol whitespace))) ;;; Hooks & Advice @@ -139,7 +145,7 @@ For entry into `lui-formatting-list'." "What to do with `circe-server' buffers when created.") (el-patch-defun circe (network-or-server &rest server-options) - "Connect to IRC. + "Connect to IRC. Connect to the given network specified by NETWORK-OR-SERVER. @@ -157,16 +163,16 @@ All SERVER-OPTIONS are treated as variables by getting the string 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)))) + (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)))) ;;; Chat commands @@ -177,7 +183,7 @@ See `circe-network-options' for a list of common options." nil t nil))) (circe-command-ME (format "slaps %s about a bit with a large trout" nick))) -;;; Filtering functions +;;; Filtering functions --- XXX: These don't work right. ;; Set `lui-input-function' to `+lui-filter', then add the filters you want to ;; `circe-channel-mode-hook'. -- cgit 1.4.1-21-gabe81