I’ve followed an earlier note to use readline instead of building from scratch and it worked up to this point by hooking custom functions.
This stage requires a specific format of completions, which uses a different separator than the default.
The closest thing I found is rl_completion_display_matches_hook which does the job, but loses the prompt in the process and any extra readline function I call to remedy that gives me a segfault.
Now I wonder if readline is the tool for this job? I must be missing something.
You’ll need to trigger the bell (return NULL from the completion() function) when there are multiple matches (the first time), instead of returning rl_completion_matches(text, generator) directly.
Not sure I follow, to be honest (haven’t used readline before). Do you mean to skip rl_complete_matches call, generate and output the complition list in completion() and then return NULL? I see this triggers the bell and passes the bell part of the test, Thanks
I noticed that after I replied So I guess restoring the prompt is the last obstacle (rl_restore_prompt() is only a partial solution), but I’ll take another look at the docs, thanks for a quick reply!
Got stuck on this one - it works as expected locally, I can type after completion and there’s a space between that and the completed command.I wonder why that space is not detected by the tester.
Actually, it’s visible in the tester if I type something extra after the space. It’s almost as if the prompt is trimmed of trailing whitespace in the tester, but that’s highly unlikely.
I could be wrong, but as long as the completion() function returns the correct matches (or NULL), readline should take care of the output formatting automatically.
Wow, I never tried simply returning matches for whatever reason…Talk about overcomplicating a problem. You’re right, it just works. Well, at least I learned a few other things about readline Thanks!