From 80547e374019f2e7b5fd31df6a7f66c63268391f Mon Sep 17 00:00:00 2001 From: snmsts Date: Tue, 30 Jul 2024 22:58:32 +0900 Subject: [PATCH] don't push duplicate commands --- lib/main.lisp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/main.lisp b/lib/main.lisp index 69733dc..d8187f4 100644 --- a/lib/main.lisp +++ b/lib/main.lisp @@ -260,14 +260,19 @@ (defun sub-command-filter (prefix) (cdr (or (gethash prefix *sub-command-filter*) - (let ((sub-commands - (loop for system-name in (remove-if-not - (string-start-with-filter prefix) - (asdf:registered-systems)) - for command = (command system-name) - do (message :sub-commands "sub command candidate for ~S ~S ~A" prefix system-name command) - when command - collect command))) + (let ((sub-commands)) + (loop with system-names = (remove-if-not + (string-start-with-filter prefix) + (asdf:registered-systems)) + for system-name in system-names + for command = (command system-name) + do (message :sub-commands "sub command candidate for ~S ~S ~A" prefix system-name command) + when (and command + (not (find (clingon.command:command-name command) + sub-commands + :test 'equal + :key 'clingon.command:command-name))) + do (push command sub-commands)) (setf (gethash prefix *sub-command-filter*) (cons t sub-commands)))))) (defun sub-commands ()