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
customizable default action and flags for commands #1008
Conversation
This slightly breaks |
Agreed, but perhaps the entire I propose updating this pull request to remove all of the existing |
If it helps I could also add a command to set default actions and flags with nice read-from-minibuffer prompts. |
I like to turn on whitespace ignoring just depending on what diff I'm viewing, I don't want it in all magit buffers. Your patch actually doesn't break this use case, just the UI of the popup becomes a little inconsistent (you can't use it to see what options are currently set). |
Ah, thanks for explaining, I've just pushed up an additional commit which resurrects the display of these options in the UI popup. |
Introduces the magit-command-defaults customization variable which allows users to specify default flags for the pop-up command interface and/or default actions to run without raising the pop-up command interface at all. See the documentation of magit-command-defaults for full usage information. The default value of magit-command-defaults adds this "--graph" flag to the logging command, this kludge was originally hard-coded into the magit-key-mode-generate function. This commit retains the special handling of local diff options saved in magit-diff-options. Thanks to npostavs on github for pointing this out.
I just pushed up a new version of this branch which simplifies the code and removes the need to re-generate magit-key-mode functions after resetting the value of magit-command-defaults. |
If I had more time I would have written a shorter comment :-) I was a bit shocked when this pr arrived. Let me explain. Two days earlier I got frustrated with the lack of progress in the key-mode department. Remember this is actually one of the areas that I would very much enjoy working on, but I have originally chosen to delay doing so, in order to not further jeopardize the goal of an "immanent release". Well, two days ago I decided that enough is enough, and that for a change I wanted to work on some features I myself am longing for (instead of architectural cleanup and features I am being asked to implement) and starting hacking. Out of necessity and habit I started by cleaning up the existing key-mode code. After a day's work I had reduced the code to half of its original size, with no loss of (significant) functionality, and while keeping the changes atomic and gaining a few minor features and abstractions for future development along the way. At that point I was both hopeful [1] and a bit frustrated [2].
At that point I started to think that I should have stuck to my original plan: implement a new mode, inspired by So I took a break and made the mistake of having a look at the Magit issue tracker as part of that. That's when I saw your pr... after the work I had done just before your pr came in, your patch no longer applied... not as a patch and also not conceptually... and now I would have to explain that to you... So I took another break, this time for two days, to consider what my options are and this is what I arrived at:
So basically I had to decide between (a) making someone happy now at the cost of making someone unhappy later on, and write code I already knew I would later throw away; or (b) making someone unhappy now and not write any code. I have chosen (b) because its opportunity cost is 0 while that of (b) is 1. But the situation has changed: time has passed and I have not written the improved key-mode. I have looked at your patch and while I now agree that this is the right thing to do at this point, there are some problems with the actual implementation. Tomorrow I will write my own variant and merge it into A very general description of what is not so good with you implementation is this: it changes the behavior in unexpected and potentially destructive ways. And then a few minor things. |
So after having looked at your proposed patch and having tried to implement this myself, I have to take back some of the things I have said above. Even when ignoring all the bugs in you patch and that it is rather naive, this is not how it should be done, not even with the current implementation. The current implementation is completely insufficient for this, and we should not try to go beyond its boundaries like this. I am very disappointed in myself for once not having brought up the strength to say no. Now my answer is just that: a strong and definite no. There is still hope for those wanting these features. I have already started working on Your patch (as well as mine) attempted to do two things:
If you want to keep going down this rabbit hole I recommend you have a look at my attempt which I have pushed to: https://github.com/tarsius/magit/tree/dead/key-mode-defaults. The doc-strings are probably more valuable than the code. |
Can you articulate a specific bug or problem with this patch?
Without any technical specifics I have no idea what the above is supposed to mean. I've been using this functionality as implemented by this patch for a while now and I find that it works well, so I disagree that it is impossible.
I thought about this some recently. To my mind the simplest solution is to absorb the first prefix argument by key-mode and pass along any additional prefix arguments to the default action. I don't know of any key-mode commands which take complex prefix arguments and thus wouldn't work with this scheme.
Since when do Emacs packages avoid adding functionality simply because it could be miss-used? Anyway, I'm happy for you to not merge this, and I'm happy to keep using it (and the multi-proc support) from my own fork. In the future it would be nice to know what functionality has any chance of being merged before submitting a pull request, but without an active mailing list I don't see how this could happen. Thanks for your consideration. |
I am glad you take it in this light. I do realise I am coming on strongly here (and a bit insecurely :-/).
The issue tracker might not be as convenient, but you can make you intentions to work on something known here.
Thanks for your understanding :-) To the other questions I will reply later. Meanwhile please have a look at my patch, especially the doc-strings, I think it addresses some of them. |
Introduces the magit-command-defaults customization variable which
allows users to specify default flags to select in the pop-up command
interface and/or default actions to perform without raising the pop-up
command interface at all.
See the documentation of magit-command-defaults for full usage
information. The default value of magit-command-defaults is taken from
two hacks previously hard-coded into the magit-key-mode-generate
function.