Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add --exclude option #19

Merged
merged 4 commits into from
Mar 3, 2024
Merged

Conversation

aymanosman
Copy link
Contributor

@aymanosman aymanosman commented Nov 16, 2023

I often need to use the --exclude option. This PR adds support for it.

Thanks to transient, it also supports supplying multiple --exclude options and the values supplied can even be saved for later invocations by transient-set usually bound to C-x s (See Saving Values).

Screenshot 2023-11-17 at 13 06 11

Thanks to transient, the following useful features are also supported:

- repeated `--exclude` options
  E.g. entering `--exclude=a,b` in the minibuffer will result in
  `--exclude=a --exclude=b` being passed to the test command
- The value(s) can be temporarily saved by `C-x s`
  to avoid having to type them in every time
@ananthakumaran
Copy link
Owner

Sorry about the late reply. I haven't looked into the details, is there any way we can make a transient definition user configurable?

@aymanosman
Copy link
Contributor Author

Sorry about the late reply. I haven't looked into the details, is there any way we can make a transient definition user configurable?

I'm not too familiar with how transient works and I'm not sure what kind of configurability you are suggesting. If you tell me what kind of user customisation you'd like to see, I could investigate whether it is possible.

@ananthakumaran
Copy link
Owner

I'm not sure what kind of configurability you are suggesting.

Let's take the current example, you are proposing to add --exclude, we have only fixed space available on UI, so the package has to take a call on whether to include the flag or not. If that could be done by the user directly, that would solve the UI space problem. Basically, as a User, I should be able to add my own flags.

@aymanosman
Copy link
Contributor Author

Cool, I’ll see if this can be done with transient.

@aymanosman
Copy link
Contributor Author

aymanosman commented Feb 6, 2024

@ananthakumaran So, there are a couple of options of how to implement this which I got from this discussion on reddit

  1. Use the :if parameter of a transient command

A patch would look like this:

diff --git a/exunit.el b/exunit.el
index 1b61c4d..009b66b 100644
--- a/exunit.el
+++ b/exunit.el
@@ -39,12 +39,18 @@

 ;;; Private

+(defcustom exunit-transient-extra-flags '(--exclude)
+  "Controls the extra flags available in the transient interface"
+  :type '(repeat string)
+  :group 'exunit)
+
 (transient-define-infix exunit-transient:--exclude ()
   :description "Exclude"
   :class 'transient-option
   :multi-value 'repeat
   :shortarg "-e"
-  :argument "--exclude=")
+  :argument "--exclude="
+  :if (lambda () (memq '--exclude exunit-transient-extra-flags)))

 (transient-define-prefix exunit-transient ()
   "ExUnit"
  1. Set the "level" of the command above the transient-default-level

The patch would look something like this:

diff --git a/exunit.el b/exunit.el
index 1b61c4d..28eb059 100644
--- a/exunit.el
+++ b/exunit.el
@@ -53,7 +53,7 @@
     ("-s" "Stale" "--stale")
     ("-t" "Trace" "--trace")
     ("-c" "Coverage" "--cover")
-    (exunit-transient:--exclude)]
+    (exunit-transient:--exclude :level 5)]
    [("-z" "Slowest" "--slowest=10")
     ("-m" "Fail Fast" "--max-failures=1")]]
   ["Actions"

[2024-02-08 Edited the diff for the levels change because it turned out to be simpler]

I'm not that familiar with this part of transient, and I'm not sure how familiar most users are with it either.

@ananthakumaran
Copy link
Owner

Thanks for checking, I am leading towards using level since that seems to be designed to solve this exact issue. I understand there is a discoverability issue, but we could put a note about the transient level. Let me know what you think. If you agree go ahead and update the PR, I will test it.

@aymanosman
Copy link
Contributor Author

I went ahead and implemented the change using the "levels" functionality. I added a note in the readme that shows users how to make the extra --exclude switch visible.

@ananthakumaran ananthakumaran merged commit 5e8f6b6 into ananthakumaran:master Mar 3, 2024
3 of 4 checks passed
@aymanosman aymanosman mentioned this pull request Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants