Ludovic Courtès (2015-06-07 18:36 +0300) wrote: > Alex Kost <alez...@gmail.com> skribis: > >> It should complete almost everything except suboptions of subcommands, I >> mean those ‘import’ modules (e.g., it will not complete >> ‘--no-test-dependencies’ option for ‘guix import hackage’ command). > > I think that’s fine. We wouldn’t want to maintain relatively custom > completion code for all these things anyway. > > However it’s important to fall back to file name completions for things > that are not handled, so that at least it is not worse than without the > pcomplete code.
Yes, it is the current behaviour (I mean the file names completion). >> Completing may lag a bit from time to time. It happens because shell >> commands (like ‘guix ... --help’) are called when necessary to find >> options, packages, etc. But the found entries are "memoized" so next >> time the same entries will be completed much faster. > > I wonder if ‘guix-pcomplete-run-guix’ couldn’t run the command in a REPL > instead of spawning a process. That is, when completing ‘guix build’, > it would evaluate something like: > > (with-output-to-string > (lambda () > (catch 'quit > (lambda () > ((@ (guix scripts build) guix-build) "--help")) > (const #t)))) > > How does that sound? It was the initial deliberate decision to separate completions code from interacting with "guix repl", to make completing independent. I imagine that a user wouldn't like to see that some "Guix REPL has been started" just because he presses TAB after ‘guix pa’ in his shell buffer. Well, at least I wouldn't use such strange completions. I think lags made by spawning the guix processes are bearable and not repeatable (I mean the next time ‘guix pa’<TAB> is completed immediately), so I would not like to change the code to use a REPL if you don't mind :-) (Perhaps in the future there will be added some option (e.g., a boolean `guix-pcomplete-use-repl' variable) to choose what a user prefers) >> Many thanks to Ludovic for the great idea of this package! > > Well I’m always impressed by your productivity! Thanks, but it is far from yours!! >> From 9ed30b97519afad84c58f1a7166f11a5e22ecda1 Mon Sep 17 00:00:00 2001 >> From: Alex Kost <alez...@gmail.com> >> Date: Sat, 6 Jun 2015 22:19:51 +0300 >> Subject: [PATCH 2/2] emacs: Add shell completions for "guix" command. >> >> * emacs/guix-pcomplete.el: New file. >> * emacs.am (ELFILES): Add it. >> * doc/emacs.texi (Emacs Completions): New node. > > LGTM! OK to push. [...] >> + ((and (command? "publish") >> + (option? "-u" "--user")) >> + (complete* (pcmpl-unix-user-names))) >> + >> + ((and (command? "refresh") >> + (option? "-s" "--select")) >> + (complete* guix-pcomplete-refresh-subsets))))) > > I like that this is very accurate. I was first slightly concerned about > the risk of this becoming out of sync, but I think we’d quickly notice > and it seems easy to update anyway. Yes, I think we'll notice, thanks. I have pushed this commit, so if someone notices that something is not completed properly, please report. -- Alex