From: plugd Date: Sat, 26 Aug 2023 08:16:49 +0000 (+0200) Subject: Nick completeion avoids @s, added /users. X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=commitdiff_plain;h=ae91c63db174acd4a59ec169f971c3aca95f6856;p=lurk.git Nick completeion avoids @s, added /users. --- diff --git a/lurk.el b/lurk.el index edfb66f..bf8f254 100644 --- a/lurk.el +++ b/lurk.el @@ -890,6 +890,7 @@ in which case they match anything.") ("NICK" "Change nick." lurk-command-nick) ("LIST" "Display details of one or more channels." lurk-command-list) ("WHOIS" "Ask server for details of nick." nil lurk-nick-completions) + ("USERS" "List nicks of users in current context." lurk-command-users) ("MSG" "Send private message to user." lurk-command-msg lurk-nick-completions) ("CLEAR" "Clear buffer text." lurk-command-clear lurk-context-completions) ("HELP" "Display help on client commands." lurk-command-help lurk-help-completions)) @@ -1032,6 +1033,15 @@ in which case they match anything.") (dolist (context params) (lurk-clear-context context)))) +(defun lurk-command-users (params) + (if lurk-current-context + (progn + (lurk-display-notice lurk-current-context "Users in context:") + (lurk-display-notice + lurk-current-context + (string-join (lurk-get-context-users lurk-current-context) " "))) + (lurk-display-notice nil "No current channel."))) + ;;; Command entering ;; @@ -1114,7 +1124,7 @@ in which case they match anything.") (defun lurk-complete-input () (interactive) (let ((completion-ignore-case t)) - (when (and (>= (point) lurk-input-marker)) + (when (>= (point) lurk-input-marker) (pcase (buffer-substring lurk-input-marker (point)) ((rx (: "/" (let cmd-str (+ (not whitespace))) (+ " ") (* (not whitespace)) string-end)) (let ((space-idx (save-excursion @@ -1135,7 +1145,11 @@ in which case they match anything.") (re-search-backward " " lurk-input-marker t))) (start (if space-idx (+ 1 space-idx) lurk-input-marker))) (unless (string-prefix-p "/" (buffer-substring start end)) - (completion-in-region start end (lurk-get-context-users lurk-current-context))))))))) + (let* ((users (lurk-get-context-users lurk-current-context)) + (users-no@ (mapcar + (lambda (u) (car (split-string u "@" t))) + users))) + (completion-in-region start end users-no@))))))))) (defun lurk-enter () "Enter current contents of line after prompt."