From 191b189b97915566a5fee5fcde4dd3f88e67bf61 Mon Sep 17 00:00:00 2001 From: plugd Date: Mon, 20 May 2024 00:38:05 +0200 Subject: [PATCH] Joins/parts update context users. --- murk.el | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/murk.el b/murk.el index ffe10e6..2e89982 100644 --- a/murk.el +++ b/murk.el @@ -57,6 +57,9 @@ "IRC networks." :type '(alist :key-type string)) +(defcustom murk-show-joins nil + "Set to non-nil to be notified of joins, parts and quits.") + (defcustom murk-display-header t "If non-nil, use buffer header to display current host and channel." :type '(boolean)) @@ -359,6 +362,11 @@ The head of this list is always the current context.") ctx (cl-union users (murk-context-users ctx)))) +(defun murk-del-context-user (ctx user) + (murk-set-context-users + ctx + (delete user (murk-context-users ctx)))) + ;;; Buffer ;; @@ -657,6 +665,15 @@ The head of this list is always the current context.") "Joining channel " channel " on " server) (murk-render-prompt))) + ("JOIN" + (let* ((channel (car (murk-msg-params msg))) + (nick (murk-msg-src msg)) + (ctx (murk-get-context server channel))) + (murk-add-context-users ctx (list nick)) + (if murk-show-joins + (murk-display-notice ctx nick " joined channel " channel + " on " server)))) + ((and "PART" (guard (equal (murk-connection-nick server) (murk-msg-src msg)))) @@ -665,6 +682,15 @@ The head of this list is always the current context.") (murk-remove-context (list server channel)) (murk-render-prompt))) + ("PART" + (let* ((channel (car (lurk-msg-params msg))) + (nick (lurk-msg-src msg)) + (ctx (murk-get-context server channel))) + (murk-del-context-user ctx nick) + (if murk-show-joins + (murk-display-notice ctx nick " left channel " channel + " on " server)))) + ("QUIT" (let ((nick (murk-msg-src msg)) (reason (mapconcat 'identity (murk-msg-params msg) " "))) @@ -715,6 +741,7 @@ The head of this list is always the current context.") (defvar murk-command-table '(("DEBUG" "Toggle debug mode on/off." murk-command-debug murk-boolean-completions) ("HEADER" "Toggle display of header." murk-command-header murk-boolean-completions) + ("SHOWJOINS" "Toggles display of joins/parts." murk-command-showjoins murk-boolean-completions) ("NETWORKS" "List known IRC networks." murk-command-networks) ("CONNECT" "Connect to an IRC network." murk-command-connect murk-network-completions) ("QUIT" "Disconnect from current network." murk-command-quit) @@ -766,6 +793,16 @@ The head of this list is always the current context.") (setq-local header-line-format nil) (murk-display-notice nil "Header disabled."))) +(defun murk-command-showjoins (params) + (setq murk-show-joins + (if params + (if (equal (upcase (car params)) "ON") + t + nil) + (not murk-show-joins))) + (murk-display-notice nil "Joins/parts will now be " + (if murk-show-joins "shown" "hidden") ".")) + (defun murk-command-clear (params) (if (not params) (murk-clear-buffer) -- 2.20.1