-
Notifications
You must be signed in to change notification settings - Fork 7
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
Move over to Transient #15
base: master
Are you sure you want to change the base?
Conversation
- Use double dash for internal variable. - Update docstrings. - Use more idiomatic standard library functions.
4ac77e3
to
28e872e
Compare
You can use the same function for both tasks, see |
This is great! Thank you, @hokomo. Here's answers to your specific questions for me. I'm going give this PR more review and exercise the changes over the next few days.
Yes, any long option that takes a value may use either
What comes after a
It is only commands with the last form, i.e. those that only have patch arguments and do not take pathspec arguments, that a superfluous |
Same here, except I am going on a mini-vacation soon, so it will take a bit longer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this looks really clean and on-target for the goals you stated--really well done and a great step forward!
I am unable to run a several commands due to the use of the undefined first
function (see comment for details). I may have more comments once that issue is resolved.
Also, I am also still trying to figure out the best way to load/enable this extension in my doom-emacs setup. I can get it working with a combination of config-time and runtime hacks, but I don't yet have a clean/reproducible way to turn-on magit-stgit
. I'm not yet able to tease apart what might be intrinsic to doom-emacs versus my doom configuation versus the magit-stgit
extension itself. So this is something that I'll continue to try to get to the bottom of.
(let ((field (match-string 1)) | ||
(recipient (match-string 2))) | ||
(when (string-match "<" recipient) | ||
(setf (alist-get field fields nil nil #'equal) recipient))))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see a lint that using alist-get
demands a minimum emacs version of 25.1. whereas the current requirement is emacs 24.4.
Seems like upping the minimum emacs version to 25.1, which was released in 2016, should be reasonably uncontroversial.
That said, one thing I experimented with was whether removing the dash
dependency would be feasible. If we were to set the minimum emacs to 27.1 (2020-08-10), then we could use the builtin flatten-list
instead of -flatten
and a (flatten-list (mapcar ...))
instead of -mapcat
to eliminate dash.
I'm comfortable with having emacs 27.1 as the minimum version if it enables removal of a dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch. Perhaps we should set up some Makefiles soon to make the compilation reproducible? I think at least a couple of times the byte-compiler didn't manage to catch some issues for me just because there's always a bunch of stuff loaded into my Emacs. I've noticed @tarsius already has a streamlined set of scripts that he uses in his packages, so maybe we should use something similar. :-)
I'm comfortable with bumping up the version as well, even as high as 27.1, as I use at least Emacs 28 on all of my machines. Given that we would like to target StGit 2.0 which is even more cutting edge, I don't think this would be too big of a deal, but perhaps some people might want to use an older version of Emacs while testing out StGit 2.0? @tarsius Given that you have a lot of experience as an Emacs package maintainer, do you have any thoughts on this (and also regarding the appropriate versions of Magit and Transient)?
Thanks! Take your time, both. :-)
I was wondering if I should use that for all of the commands. I haven't yet gone through to try and identify if and how much of argument gymnastics might be required, but I've been thinking about the non-transient interactive interface that each command provides. At first it seemed like we're effectively duplicating work and implementing a subset of the interactivity that the transient already gives us. But on a second thought, that kind of interface is sort of necessary, since we definitely want to be able to call the commands with the point on a patch in the StGit section, etc. I'll give it some thought and check if there are any cases where stuffing all of it in a transient would just complicate things. In case it turns out to be too complicated, we might want to have the separation after all, in which case we need to think of some better names.
I see. I just realized I'm on StGit 1.4 since that's what my package manager has. Here's an example of what I see in the manpages:
Which in StGit 2.0 becomes:
I'll rework the code to drop the |
Thanks! :-) I'll address your comments with some new commits soon.
Ah, that should be
I'm assuming the hook mentioned in the file's commentary is not enough? That's the only thing I've had to add, and I don't think Spacemacs has any special functionality for StGit. |
@jpgrayson Since we plan on using StGit 2.0 as a base, but it hasn't even been released yet, do you think we should try and check (in a future PR perhaps) that the user is running version 2.0 and issue an appropriate error if not, until version 2.0 becomes the norm? |
Thanks for bringing up the possibility of patch names starting with "-". I thought "surely such patch names are prohibited by StGit", but I was able to use
No, the On this topic, why is there a
Yes, but a warning instead of an error. We most StGit commands, with the notable exceptions of |
Thinking more about the keys, I'm not so sure if Are there any other options we can use? I'll leave it on |
I suppose it's just to provide the ability to toggle the presence of the patch section. I have nothing against following the same pattern since I doubt you'd want to frequently enable/disable Speaking of top-level transients, I will rename |
28e872e
to
fd44111
Compare
Require a match when prompting for a patch.
Require a match when prompting for a patch.
- Prompt for a patch as a last resort and require a match. - `magit-stgit-read-patches' now properly returns nil instead of '(nil) when reading a patch at point or from the minibuffer fails. - Take care to look out for `--all` and `--number`, in which case we want to ignore any patches specified to the function.
Require a match when prompting for a patch.
Extract and rewrite the cover letter searching functionality to be more idiomatic.
fd44111
to
d7468dd
Compare
I've now dropped all of the @jpgrayson One thing that caught my eye is
That should most likely be |
Good catch. The default usage is generated by clap based on the defined arguments. In the case of
N.B. it seems unlikely that we would want to go to the effort to support |
I'm pretty happy with the latest set of commits in this PR. I'd like @tarsius' feedback too, of course, but from my perspective these changes are good foundation to keep building on. Not sure what process we want to use for PR's and other changes to this repo. If you want to either merge this PR yourself or push your changes directly, that would be okay with me. If you're more comfortable with someone else gatekeeping changes, I can merge the PR. You're doing a big lift here, which I appreciate, so I'd like the process to be most helpful to you. |
Speaking just for magit-annex, if I were to write it today, I wouldn't add the key to Re minor mode: I haven't looked at the code in this PR, but, for what it's worth, I think that's a good (and idiomatic) way to let users toggle this package's changes to Magit's modes. |
I think the instructions must be pretty old, since I can't find
If I understood you correctly, I believe you have to manually refresh Magit's status buffer if you've made changes to the repo outside of Magit. |
I don't mind merging or pushing directly myself. :-) The only question that I have is what sort of git workflow we prefer. Usually I like to rebase on top of master to keep the history nice and clean (I suppose this is what you meant by pushing directly). Any opinions on whether some of the commits in this PR should be squashed when the time comes?
That sounds good to me actually, since we can avoid making that tricky decision. I'm assuming we don't need to do the same for the series section key bindings since these are very localized anyway.
Thanks for the input! After giving it a second thought, I think I'm leaning more toward keeping it around after all, because why not give the users the ability to toggle the functionality when it's not too much work anyway. :-) |
No, I was talking about if/when/how modified
I like a linear history as well. Rebasing is good. Regarding pushing directly vs. going through a PR: I make a distinction between classes of changes that warrant review vs. those that don't. Since we've started a PR for these changes, we should finish the PR with a "Rebase and merge" when the time comes. I'm anticipating other changes you or I will want to make that do not warrant a PR workflow. I'm thinking of docstring changes or trivial/obvious repairs.
I wouldn't squash these changes; it's a nice series.
I concur. Also, I really appreciate @kyleam chiming in on this PR. I'm now using |
Ah, I see what you mean, and I completely agree on both points (landing PRs by rebasing, and not opening PRs for trivial fixes).
Ok. :-) |
Here it is as promised. Suggestions welcome!
I've kept the conversion of each command as a separate commit so that it's easier to follow and review, but we can of course squash some of these later if this is too verbose.
The conversions all share a pattern -- convert the popup to a transient and slightly rework the corresponding command (update the docstring, make the code more idiomatic, fix any easy stuff, etc.).
As mentioned, I've tried not to break or significantly change any existing functionality, but I did take the opportunity to change a couple of small things here and there. In particular:
We now require a minibuffer match when edit, refresh and sink (its target) prompt for a patch. Since
magit-stgit-read-patches
doesn't have a parameter for a default, I've removed the defaults from the prompts for now (not requiring a match and manually handling empty input, as the code was doing, is not the best way to handle the default I think).The commit command now also tries to read a patch from the minibuffer as a last resort (I'm not sure why the code was passing
t
forREQUIRE-MATCH
but thennil
forPROMPT
, tomagit-stgit-read-patches
).The commit function now takes care to look out not just for
--all
but also--number
. If these are specified,PATCHES
is ignored (I don't know exactly why the code was expecting to find just a single patch in case of--all
).Questions:
I don't know what names to use to differentiate between the transient and the function that does the work. Before we used to have the
-popup
suffix. For now I just decided to temporarily name themmagit-stgit-CMD
andmagit-stgit--CMD
. The double-dash name is definitely not good, as they're all public functions that the users can use (both interactively and programmatically). Ideas?Almost all of the commands rely on
magit-stgit-read-patches
to try and gather some patches. When it inspects both the region and the point, I've documented this as "patches around point"; when it inspects the point but not the region, I've used "patch at point" instead; and when it prompts for a patch, I've used "read one from the minibuffer". Is the around/at distinction good enough?My
magit-stgit--commit-need-patches-p
has to handle both--number
and--number=
, since we wantmagit-stgit--commit
to be able to function regardless of the syntax the user/programmer decides to use for the options and whether or not it was invoked through Transient. There's no way around this, right?The key binding for the main
magit-stgit
popup was/
, which I've left as is and added just after the Forge@
key binding inmagit-dispatch
. Any better ideas?Questions @tarsius:
I used Transient 0.3.7. Is this too recent to use as a requirement?
magit-define-popup
usedmagit-stgit-commands
as the Custom group. I wasn't able to find the equivalent of this in Transient so I removed it for now.I assume
transient-current-prefix
is the equivalent ofmagit-current-popup
.I've used
:man-page
in all of the prefixes, but how do I do it for suffixes (e.g.magit-stgit-init
)?Do infix arguments have to be strings, i.e. do I have to use
number-to-string
afterread-number
?Is there any benefit to always mentioning both the short and the long form for a Transient option (using a list of the form
(SHORT LONG)
)? Right now I don't do this anywhere.Questions @jpgrayson:
I assume StGit guarantees that it supports both
--long-option VAL
and--long-option=VAL
option syntax, right?I've explicitly used
--
as a separator when invoking StGit commands to be able to handle any funny patch names. Could this be a problem, according to stacked-git/stgit@7b87a0d?