-
-
Notifications
You must be signed in to change notification settings - Fork 66
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
transient-append-suffix can't add multiple keys with different conditions #106
Comments
It looks like this might be related to the change done for bug #58. The check for duplicate keys which seems to cause the issue is at 1054 in transient--insert-suffix: (if (equal (transient--kbd key)
(transient--kbd (transient--spec-key elt)))
(setq action 'replace) |
Thanks for a nice bug report. I especially appreciate that you posted a test case.
It might be related in the sense that this commit fixes and/or adds bugs which may affect how this function behaves with regards to what we are discussing here, but if that is so, then that was unintentional at the time. Going throw the trace log of this function is quite interesting but also embarrassing.
That's a reasonable expectation and I agree but unfortunately this conflicts with another reasonable (and older) expectation. In other words things are actually behaving as expected and I am not sure how to reconcile the two conflicting expectations. Initially "conflicting" bindings were not allowed, there were no How the old conflicting binding was removed has changed a few times to handle edge-cases and fix bugs that were introduced in the process. But "conflicting bindings" were intentionally removed from the very beginning (even when using the insert/append commands, not just when using the replace command). The reason is documented in one of the commits that touch this function:
By now (seemingly) conflicting bindings are allowed, but that does not mean that any such shared binding is intentional, some are real conflicts and I don't know yet how to tell them apart. For example the very same |
I see. How about adding another possible flag for this? Like |
I've decided to go with a heuristic for now. |
When adding new keys using
transient-append-suffix
it is not possible to have the same key several times with different conditions:Now we have only one entry with a key called "s". See the output of
(prog1 nil (pp (transient-get-suffix 'shk-bug-repro (list 0))))
:Doing the same using only
transient-define-prefix
is possible as running this code shows:producing the expected result
I would expect the two ways to define this menu to be equivalent.
The use case in this example might seem a bit hackish (using something as a suffix which might map better to an infix argument/toggle) but I find it useful for a quick sub mode to toggle minor modes where I'd prefer to not having to prefix everything with an extra "-". Another use case for several "overloads" of the same key would be org-mode where different functions need to be called to navigate depending on what kind of syntax we're on (table, header, etc.).
Transient version is transient-20201102.2024 (via Melpa), Emacs is 27.1 (up to date Manjaro Linux), Magit (if it matters?) is magit-20201116.1057 (via Melpa)
The text was updated successfully, but these errors were encountered: