Fixed nick completion in commands. master
authorplugd <plugd@thelambdalab.xyz>
Sat, 26 Apr 2025 08:37:25 +0000 (10:37 +0200)
committerplugd <plugd@thelambdalab.xyz>
Sat, 26 Apr 2025 12:42:25 +0000 (14:42 +0200)
lurk.el

diff --git a/lurk.el b/lurk.el
index 8114597..e74334d 100644 (file)
--- 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
 ;;