Open ParetoOptimalDev opened 1 year ago
I tried naively adding .#
to nix--pcomplete-flags even though it's not a flag and that didn't work:
("build"
(nix--pcomplete-flags
(append nix-toplevel-options '("--arg" "--argstr" "--dry-run"
"-f" "--file" "-I" "--include"
"--no-link" "-o" "--out-link" ".#"))))
For others toying around with this or other nix related (p)completion I found this to be a useful resource:
https://www.masteringemacs.org/article/pcomplete-context-sensitive-completion-emac
I tried using edebug to understand pcomplete/nix
and figured out that while nix build
hits its code path, nix build .
hits it, nix build .#
does not.
.#
seems to be special in emacs completion somehow and this special behavior will need to be overriden to get completion for it.
.#
is special because it's an eshell glob. I can progress a bit further following the control flow in edebug by removing #
from eshell-glob-chars-list
but things aren't quite working. I think it's because the command getting run and it's result is:
~ $ NIX_GET_COMPLETIONS=2 nix build .#
attrs
It wouldn't be correct, but I'd expect at this point to get attrs
as a completion candidate.
Oh, actually it's working! I just wasn't in a directory with a flake. So this works (if the code is correct):
(setq eshell-glob-chars-list '(93 91 42 63 126 40 41 124 94))
And then adding .#
in:
("build"
(nix--pcomplete-flags
(append nix-toplevel-options '("--arg" "--argstr" "--dry-run"
"-f" "--file" "-I" "--include"
"--no-link" "-o" "--out-link" ".#"))))
Ideally though we could avoid removing .#
as a glob and only treat it as a glob when it's not preceded by nix build
. I don't have time to look into right now though.
And other situations, here's copy paste of my org mode todo:
Right now eshell just falls back to completiing it into a directory for some reason.