I could be missing something, but I think a filename completion procedure (not the DrRacket integration part) might be a doable exercise for a budding Racket programmer, so long as they already have a basic familiarity with using the filesystem and shell as a normal user.

Point them to the "Paths" and "Filesystem" sections of the Racket Reference, and tell them they just need a few procedures from each (probably including `split-path` and `directory-list`).

They might want to first make a procedure like this:

(path-completions path-or-string?)
==> (listof completion-string)

And then make a second procedure, which uses the first procedure, then adds an additional step, to let it return two values instead of one:

(path-completion-prefix-and-suffixes path-or-string?)
==> (values prefix-string-shared-by-all-completions
            (listof completion-remainder-after-any-shared-prefix-string))

Then, when a user is interactively doing completion (like when they hit the Tab key in a shell), the first value returned by that second procedure is what would get added automatically to the path.  The second value is the list of possible completions following that shared prefix.

There are a few special cases to consider, but most should be easy to recognize and work through, just by thinking methodically about each point in your code.  For example, what do you do when the input path is relative, or when when there are no completions, or when the path is invalid or nonexistent or permissions-inaccessible, or when your path is already complete.  One case that's not obvious from the code: if the path is already complete and is a directory, a shell usually completes a directory separator, so consider whether you want to do that.

To make unit tests for these, they'll have to also look at more of the "Filesystem" section of the Racket Reference, to create and remove files and directories.

(I think wrapping a shell process, robustly, is much more difficult.)

You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to