repl: suggest quoted attribute names when necessary #450
Labels
No labels
Area/build-packaging
Area/cli
Area/evaluator
Area/fetching
Area/flakes
Area/language
Area/profiles
Area/protocol
Area/releng
Area/remote-builds
Area/repl
Area/store
bug
crash 💥
Cross Compilation
devx
docs
Downstream Dependents
E/easy
E/hard
E/help wanted
E/reproducible
E/requires rearchitecture
imported
Needs Langver
OS/Linux
OS/macOS
performance
regression
release-blocker
RFD
stability
Status
blocked
Status
invalid
Status
postponed
Status
wontfix
testing
testing/flakey
ux
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lix-project/lix#450
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Is your feature request related to a problem? Please describe.
Tab-completed attribute suggestions in
nix repl
don't work very well when they contain characters that need to be quoted (e.g..
,@
), for example:Describe the solution you'd like
Suggest e.g.
"hello@example.com"
instead ofhello@example.com
for cases like this that need to be quoted to resolve an attribute name, so that the suggestion is actually valid.Describe alternatives you've considered
Don't suggest attribute names like this at all? Seems like that would be a poor UX. No other alternatives come to mind at the moment.
Additional context
I looked into implementing this myself, and I'd like to send a patch if I can figure it out! Actually getting the quoted attribute name is pretty straightforward, but hooking the quoted completion up to
editline
seems a little harder. It appears that"
is treated as a special character denoting a new word, so once the user types a single"
the completion callback no longer sees the left-hand-side of the.
to evaluate. It looks like thereadline
equivalents forrl_completer_quote_characters
or similar are unimplemented ineditline
.From digging a bit more, in v1.16 they added some APIs which appear to be fed the entire input line, instead of just the "current word" I guess? From a little bit of experimentation it seems possible to use these to workaround the limitation above, and fall back to the current implementation in the normal case.
There's one oddity, which is that
rl_completion_entry_function
is not declared in their public header, but it is documented in the changelog and is an existingreadline
API, so it's probably fine/forward-compatible to declare it manually (and perhaps send a patch upstream to add the declaration).TL;DR
editline
doesn't handle quotes well for this caseextern
sinceeditline.h
doesn't declare itDo those caveats seem okay / should I take a stab at implementing this? It seems like a freeze-friendly kind of feature but I thought I'd start some discussion before putting too much time into it.
this is not the only issue with editline, fwiw. there have been ideas of switching lix to a different line editing framework that doesn't have these shortcomings (replxx was a contender), but so far no decision has been made on that.
sure!
rl_attempted_completion_function
is externd at least, and that seems to be the most important one for us.lix is not currently frozen, the wiki was just a bit out of date. :)
This issue was mentioned on Gerrit on the following CLs: