From: plugd Date: Sun, 19 May 2024 22:38:05 +0000 (+0200) Subject: Joins/parts update context users. X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=commitdiff_plain;h=191b189b97915566a5fee5fcde4dd3f88e67bf61;p=lurk.git Joins/parts update context users. --- 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)