darcs

Patch 1546 refactored shell completion support (and 3 more)

Title refactored shell completion support (and 3 more)
Superseder Nosy List bf
Related Issues
Status accepted Assigned To
Milestone

Created on 2017-03-30.04:42:12 by bf, last changed 2017-04-17.05:48:05 by ganesh.

Files
File name Status Uploaded Type Edit Remove
patch-preview.txt bf, 2017-03-30.04:42:08 text/x-darcs-patch
refactored-shell-completion-support.dpatch bf, 2017-03-30.04:42:08 application/x-darcs-patch
unnamed bf, 2017-03-30.04:42:08 text/plain
See mailing list archives for discussion on individual patches.
Messages
msg19408 (view) Author: bf Date: 2017-03-30.04:42:08
I should perhaps have made it clearer in the patch comment that the refactor
also changes behaviour: files completion now starts at the cwd where darcs
was invoked.

With the refactoring it is now possible to improve shell completion for
darcs in a way that takes the whole command line into account. See the
change to the replace command for an illustration. I have barely started to
use the new possibilities.

The change to the zsh completion script does not depend on the refactor but
I included it because it is thematically related.

4 patches for repository http://darcs.net/screened:

patch 4800ed861b90e94d6963ba9079725d7e6cdddeda
Author: Ben Franksen <benjamin.franksen@helmholtz-berlin.de>
Date:   Sun Mar 26 23:08:26 CEST 2017
  * refactored shell completion support
  
  - moved listFiles, listRegisteredFiles, listUnregisteredFiles
    from Darcs.Repository to their own module Darcs.UI.Completion
  - renamed them to fileArgs, knownFileArgs, unknownFileArgs
  - added to that module: noArgs and prefArgs
  - import and use these functions for commandGetArgPossibilities
  - renamed this record member to commandCompleteArgs
  - added the full command line info as extra arguments to
    this member, same as for commandCommand
  - re-implemented completion support functions to take difference
    between original cwd and repo path into account
  - incomplete: also take flags and args that are already on the
    command line into account; currently only used for --boring by
    unknownFileArgs; more are planned
  - re-implemented the only remaining (unrelated) use of listFiles in
    Darcs.UI.Command.Util
  - factored expandDirs (which used listFiles) and doesDirectoryReallyExist
    (which is called by expandDirs) from add command to Util
    since it is shared by remove command 
  - use fileArgs for apply and rebase apply instead of noArgs
  - use knownFileArgs for replace command (planned: do this only after the
    two other args have been given)
  - some small things I may have forgotten

patch 4ddee01dac242abaed1d532c94f9a105bec7f272
Author: Ben Franksen <benjamin.franksen@helmholtz-berlin.de>
Date:   Mon Mar 27 00:30:00 CEST 2017
  * complete files for darcs replace only if 2 args are already present

patch 98802f2ac1286ea24f982f6ae647999d07a12950
Author: Ben Franksen <benjamin.franksen@helmholtz-berlin.de>
Date:   Mon Mar 27 01:20:09 CEST 2017
  * use knownFileArgs, not noArgs, for show files

patch ad82b9f4b110df2924e1fa1fb6074c48a2cf6234
Author: Ben Franksen <benjamin.franksen@helmholtz-berlin.de>
Date:   Sun Mar 26 22:16:46 CEST 2017
  * re-write of zsh completion script
  
  - special case for get/clone: use built-in function _urls to get some
    sensible defaults in addition to what --list-options gives us
  - use _multi_parts with / as separator to improve (virtual) file completion
  - use separate groups for options and other arguments
  - throw out use of _wanted and _arguments: like almost all of the completion
    functions support in zsh, these are tailored to provide completion when
    there is no support from the command itself.
Attachments
msg19446 (view) Author: ganesh Date: 2017-04-16.19:27:12
>   * refactored shell completion support

Looks fine to me, especially good to see code being moved out of 
Darcs.Repository.
msg19447 (view) Author: ganesh Date: 2017-04-17.05:48:05
>  * complete files for darcs replace only if 2 args are already 
present
>  * use knownFileArgs, not noArgs, for show files

Look good

>  * re-write of zsh completion script

Looks sane, though I don't use zsh so haven't tested it
History
Date User Action Args
2017-03-30 04:42:12bfcreate
2017-03-30 04:43:08bfsetstatus: needs-screening -> needs-review
2017-04-16 19:27:13ganeshsetmessages: + msg19446
2017-04-17 05:48:05ganeshsetstatus: needs-review -> accepted
messages: + msg19447