In case anyone else finds this helpful.  I poked around the DrRacket source 
and found text:get-completions/manuals.  This gave me a thread to pull.  
After more googling, docs, and reading more source I think I can answer my 
own question.

The short answer is no.

The long answer is sort of.  If I am understanding correctly, Racket does 
not provide the capability to directly look up lexical scope aware 
completions.  But, text:get-completions/manuals in framework can be used to 
look up a list of keywords in documented exports.  That list can then be 
searched for an applicable completion for a partial word.

Not sure why I failed to find this yesterday.

Here is a quick and dirty example.  There is probably a much better way to 
do this, but I'm still learning.  I'll settle for something that just works 
for now.

#lang racket
(require framework)

(filter (lambda (x) (regexp-match #px"^def" x)) 
(text:get-completions/manuals #f))

On Wednesday, February 7, 2018 at 5:12:00 PM UTC-6, wrote:
> My google-fu is failing me today.  Is there a concise way in Racket to 
> request possible completions for some Racket code?  For example, in 
> powershell I can ask System.Management.Automation.CommandCompletion for 
> possible completions of the powershell code "ConvertTo-Json -"  like this:
> $cmd = "ConvertTo-Json -"
> $ret = 
> [System.Management.Automation.CommandCompletion]::MapStringInputToParsedInput($cmd,
> $cmd.Length)
> $candidates = 
> [System.Management.Automation.CommandCompletion]::CompleteInput(
>     $ret.Item1,
>     $ret.Item2,
>     $ret.Item3,
>     $null,
>     [System.Management.Automation.PowerShell]::Create()
> ).CompletionMatches
> $candidates | ForEach-Object {
>     [pscustomobject]@{
>         CompletionText = $_.CompletionText
>         ResultType = $_.ResultType.ToString()
>         ToolTip = $_.ToolTip
>     }
> }
> Outputs (depending on system, powershell and .net version):
> CompletionText       ResultType    ToolTip                             
> --------------       ----------    -------                             
> -InputObject         ParameterName [Object] InputObject                
> -Depth               ParameterName [int] Depth                         
> -Compress            ParameterName [switch] Compress                   
> -Verbose             ParameterName [switch] Verbose                    
> -Debug               ParameterName [switch] Debug                      
> -ErrorAction         ParameterName [ActionPreference] ErrorAction      
> -WarningAction       ParameterName [ActionPreference] WarningAction    
> -InformationAction   ParameterName [ActionPreference] InformationAction
> -ErrorVariable       ParameterName [string] ErrorVariable              
> -WarningVariable     ParameterName [string] WarningVariable            
> -InformationVariable ParameterName [string] InformationVariable        
> -OutVariable         ParameterName [string] OutVariable                
> -OutBuffer           ParameterName [int] OutBuffer                     
> -PipelineVariable    ParameterName [string] PipelineVariable           

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 
For more options, visit

Reply via email to