-
-
Notifications
You must be signed in to change notification settings - Fork 37
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
robe-completing-read
for Module:
is excessively interrupting
#144
Comments
Hi! I use Ivy for I wrote up some a couple of alternative approaches here, as you recall: company-mode/company-mode#1408 (comment) To summarize: a. The docstring is showed automatically (not after explicit Here's a couple of new variations: c. the buffer text itself will mention that there are several matching with the given name, and you'd be able to page through them by tapping d. Like a, but when there are several available options, don't show any doc (so as not to create confusion) until the user types Looks like the previous time this came up was in company-mode/company-quickhelp#8, which settled on the first part of a. I also tried to check out what VS Code does in such cases, and apparently Solargraph gives up and shows nothing in cases where it's not certain about the owner class. Which would correspond to d, though a little weaker. |
BTW, your current solution might be implemented slightly differently as well: (defun my/completing-read-without-up-down (f &rest args)
(let ((key-translation-map (define-keymap ; new in Emacs 29
"<up>" "C-g" ; maybe add C-n and C-p as well
"<down>" "C-g")))
(condition-case nil
(apply f args)
(quit (car (nth 1 args))))))
(advice-add 'robe-completing-read :around 'my/completing-read-without-up-down) That should work across completion systems, though with expected disruptive effect for Ivy and other vertical ones. |
(I use Emacs 27 😅) Thanks much for the summary. Perhaps a variation would be:
This way, I can It also seems a fairly intuituive UX, that requires no learning of extra commands. Users would be able to reuse their existing knowledge of this aspect of Company / completing-read. Hopefully it wouldn't complicate the implementation code much? For one thing, it probably would involve that the The way I'd imagine is by providing something like It would be a non-breaking API change: backends would be free to provide one or the other key (maybe both, in case the user was running an old Company) Edit: as part of that would-be design, |
Ah, okay. Only
I'm not in love with this approach myself, for two reasons: a) Ivy's prompt is disruptive for the completion popup, whether it's immediate or after 1 second, b) there is no guarantee that you're not going to want to change selection right after that 1 second timeout fires sometime. The odds of such conflict will be lower, but unexpected problems often feel more annoying than the ones you anticipate. So I'm reasonably certain you won't like this approach in end after trying it. But maybe I'm wrong. What we could do, probably, is split the change into two parts: changes to Company and Robe which implement d and a customization (or maybe an experimental patch) on top of it that calls |
It sounds reasonable to me. Although, under the would-be Otherwise, mixing Company with (I'm agnostic as for how Company would offer a 'native' UI. I'm sure that it could evolve / have a few alternatives) An additional win with |
That would be an advantage, yes. But one of these solutions I could implement in 10 minutes, and the other... 🙃 How would it look anyway? A pop up beside a pop up (harder)? Or a replacement popup (easier, but a lot more confusing from the user's POV)?
Indeed. Ido/IComplete should be the least confusing of the bunch in this context because of the horizontal rendering. |
So, if there were multiple options during a completion:
The interface would be vaguely similar to IDO, except that:
The completion popup would not be altered in any way, and it would remain open during the whole process, as usual. |
All right. It does sound nice, for the cases it would work in. Some problems:
Note that solutions a and d would also have that advantage. Although your proposed UI would make going between the choices much snappier (when there are not many of them). |
A consideration is that Robe completions seem remarkably snappy. Maybe I can go from 1 to 36 just by keeping the key held for a couple seconds? Other than Ruby, probably there aren't a lot of ecosystems where choices are so abundant. I can think of the edge case Probably all ecosystems are like that - they have type hints or some other mechanism that can narrow the choices in advance. Either way, thanks much for considering my suggestion carefully. If the endgame is that CIDER can get rid of |
Allowing external iteration through method overrides. #144
Most likely, yes. You just wouldn't be able to do what I'd usually done: start typing part of the class name (if you know it yourself already) and press RET before the list is even displayed.
One language that comes to mind is Java :-) But I suppose we only need to consider the dynamic ones, for practical purposes (even though choosing between the subclass methods of a given interface could be useful in some circumstances). In Clojure you have Anyway, this got me curious, so here's a thing to try: company-mode/company-mode@7da7869 and 00edb2a. It looks like this: Screencast from 2023-10-22 02-10-36.webm These little numbers in the bottom left are the indicator of the multiple available choices. And they're displayed through the It's not exactly like Ido, but could be, if we decide on how to display the non-selected method specs. But this section also could be moved to the doc buffer itself (the beginning), or to somewhere in the popup -- then the compactness would have its benefits. |
Hi @dgutov, those are some neat diffs and demo! It all makes sense to me. If that helps, I can implement the same would-be interface in CIDER and let you know how it works for that use case. Are the branches stable as of today? |
(Note that the video is a little outdated, as per the screenshot.) Glad you like it, and yes, more feedback on the UI and the approach would be good, including from CIDER. I'm more or less sold on the UI myself, but I haven't yet tried using it seriously in any bigger projects. And CIDER may face a peculiarity where the class names (fully qualified) are pretty long, so some shortening method could help. I can keep the branches stable, no problem. The implementation might actually change a fair bit later, but only after the UI is decided on. |
You can base off the branches |
I have this drafted, but it looks we'd need company-capf.el to be adapted as well (since that's the main 'API' used by CIDER). If it helps, here's how my tentative usage is looking like: https://github.com/clojure-emacs/cider/compare/company-variants?expand=1 Thanks - V |
Right, forgot about that. Could you try with the change I just pushed? |
Alright, I got it working! I updated the branch above accordingly. It's looking very nice - thanks, as always. I haven't implemented an indicator showing the other disambiguation candidates. Do you have a strong opinion as to whether it's backends like CIDER or Company itself that should do that? For me, leaving it to Company seems the right thing - Company has the Maybe, Company can let users choose:
My overall thinking if that parts like the CIDER doc buffers should be as 'logicless' as possible - it's not their concern to calculate completion state. |
I couldn't find a good way to do that that would work for all users, hence the idea to leave it to the backends (in
Sure, but we'd still have to decide on the choices.
By default, it's taken by the When the user just wants to disable
And seeing echo area grow past 1 line isn't to everyone's liking as well: e.g. for Eldoc there is a setting
That's also a possibility, but for now I'd rather you try implementing this on your side, and try optimizing it for your data, how it looks best. Code reuse shouldn't be a concern for now: you can copy-paste some code from Robe.
I take it you didn't like my
I was curious about the other direction as well: for example, in Robe the |
Anyway, if you wanted to implement a couple of different variants and present them for a wider discussion, that would be even better. |
I haven't forgotten about this one. Things are looking reasonable with Robe and CIDER alike - nice work with Robe! Will give further input asap - my personal backlog is clearing up finally. |
Hi @dgutov ,
I'm using Robe, company-mode and IDO.
I have
company-auto-update-doc
set to t.Under that setup, the
Module:
prompts are too high-friction. While using Company, maybe I intended to<down>
my way to methodfoo
, but methodbar
is before in the Company popup, and Robe asks me to disamgibuate theModule:
. I cannot exit that until I C-g or choose an arbitrary module.What I really want is to press
<down>
again and continue my way tofoo
.The way we solved an analog problem in CIDER was to provide this macro:
https://github.com/clojure-emacs/cider/blob/f85d5c17043a430d0bb730c6637fba52f5a7f94f/cider-client.el#L480-L500
And then one would use:
(I actually used that CIDER macro as-is with
robe-completing-read
and it worked!)I don't have a problem atm with this setup, but I figured it would be good to let you know / document a solution.
Cheers - V
The text was updated successfully, but these errors were encountered: