From: plugd Date: Sat, 26 Apr 2025 08:37:25 +0000 (+0200) Subject: Fixed nick completion in commands. X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=commitdiff_plain;h=fe07fa1dba055f5e56f988c635981c44516a48af;p=lurk.git Fixed nick completion in commands. --- diff --git a/lurk.el b/lurk.el index 8114597..e74334d 100644 --- a/lurk.el +++ b/lurk.el @@ -1042,6 +1042,11 @@ The head of this list is always the current context.") (defun lurk-context-completions () (mapcar (lambda (ctx) (lurk-context->string ctx)) lurk-contexts)) +(defun lurk-nick-completions () + (let* ((users (lurk-get-context-users (lurk-current-context)))) + (mapcar (lambda (u) (car (split-string u "@" t))) + users))) + (defun lurk-command-help (params) (if params (let* ((cmd-str (upcase (car params))) @@ -1339,13 +1344,16 @@ The head of this list is always the current context.") (let ((completion-ignore-case t)) (when (>= (point) lurk-input-marker) (pcase (buffer-substring lurk-input-marker (point)) - ((rx (: "/" (let cmd-str (+ (not whitespace))) (+ " ") (* (not whitespace)) string-end)) + ((rx (: "/" (let cmd-str (+ (not whitespace))) + (+ " ") (* (not whitespace)) string-end)) (let ((space-idx (save-excursion (re-search-backward " " lurk-input-marker t))) (table-row (assoc (upcase cmd-str) lurk-command-table #'equal))) (if (and table-row (elt table-row 3)) - (let* ((completions-nospace (funcall (elt table-row 3))) - (completions (mapcar (lambda (el) (concat el " ")) completions-nospace))) + (let* ((completion-fun (elt table-row 3)) + (completions-nospace (funcall completion-fun)) + (completions (mapcar (lambda (el) (concat el " ")) + completions-nospace))) (completion-in-region (+ 1 space-idx) (point) completions))))) ((rx (: "/" (* (not whitespace)) string-end)) (message (buffer-substring lurk-input-marker (point))) @@ -1357,12 +1365,7 @@ The head of this list is always the current context.") (space-idx (save-excursion (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)) - (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@))))))))) + (completion-in-region start end (lurk-nick-completions)))))))) ;;; Mode ;;