Skip to content

Commit

Permalink
improve(commands): make sure the same command isn't created twice
Browse files Browse the repository at this point in the history
  • Loading branch information
Walheimat committed Nov 1, 2024
1 parent c64a8b2 commit f7fa03d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ship-mate.el
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,7 @@ command."
(prompt-var (intern (format "ship-mate-%s-prompt" name)))
(key (ship-mate-command--key-for-command name key)))

`(progn
`(unless (memq ',name (ship-mate--plist-keys ship-mate-commands))
,@(delq
nil
`((defvar-local ,default-var ,default ,(format "Default for `%s'." function-name))
Expand Down
8 changes: 4 additions & 4 deletions test/ship-mate-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@
(:mock ship-mate-command--key-for-command :return key))
(bydi-match-expansion
(ship-mate-create-command test)
'(progn
'(unless (memq 'test (ship-mate--plist-keys ship-mate-commands))
(defvar-local ship-mate-test-default-cmd nil "Default for `ship-mate-test'.")
(defvar-local ship-mate-test-prompt nil "Whether `ship-mate-test' should prompt.")
(defun ship-mate-test (&optional arg) "Test the current project.\n\nSee `ship-mate-command' for behavior of ARG."
Expand All @@ -587,7 +587,7 @@

(bydi-match-expansion
(ship-mate-create-command test :key "C-o" :default "make all" :prompt t)
'(progn
'(unless (memq 'test (ship-mate--plist-keys ship-mate-commands))
(defvar-local ship-mate-test-default-cmd "make all" "Default for `ship-mate-test'.")
(defvar-local ship-mate-test-prompt t "Whether `ship-mate-test' should prompt.")
(defun ship-mate-test (&optional arg) "Test the current project.\n\nSee `ship-mate-command' for behavior of ARG."
Expand All @@ -602,7 +602,7 @@

(bydi-match-expansion
(ship-mate-create-command test :multiple t)
'(progn
'(unless (memq 'test (ship-mate--plist-keys ship-mate-commands))
(defvar-local ship-mate-test-default-cmd nil "Default for `ship-mate-test'.")
(defvar-local ship-mate-test-prompt nil "Whether `ship-mate-test' should prompt.")
(defun ship-mate-test (&optional arg) "Test the current project.\n\nSee `ship-mate-command' for behavior of ARG."
Expand All @@ -619,7 +619,7 @@
(setq key nil)
(bydi-match-expansion
(ship-mate-create-command test)
'(progn
'(unless (memq 'test (ship-mate--plist-keys ship-mate-commands))
(defvar-local ship-mate-test-default-cmd nil "Default for `ship-mate-test'.")
(defvar-local ship-mate-test-prompt nil "Whether `ship-mate-test' should prompt.")
(defun ship-mate-test (&optional arg) "Test the current project.\n\nSee `ship-mate-command' for behavior of ARG."
Expand Down

0 comments on commit f7fa03d

Please sign in to comment.