[plt-scheme] word completion for module based languages

From: Robby Findler (robby at cs.uchicago.edu)
Date: Wed Jul 2 16:25:31 EDT 2008

Thanks. I'm still hoping one of the debugger guys knows what is going
on there, but for autocompletions, you need this method:

      (define (make-mytest-plt-elk-language base)
        (class (drscheme:language:module-based-language->language-mixin

(drscheme:language:simple-module-based-language->module-based-language-mixin
                 base))
          (inherit get-language-position)
          (define/override (get-language-name)
            language-name-plt-elk)
          (define/augment (capability-value key)
            (cond
              [(eq? key 'drscheme:autocomplete-words)
               (get-all-manual-keywords)]
              [else (drscheme:language:get-capability-default key)]))
          (define (debugger:supported?) #t)
          (super-instantiate ())))

with this helper function defined yourself. I didn't export
get-all-manual-keywords since it was so short and I wasn't sure that I
would be able to support that interface indefinitely. But in any case,
it is easy to write it yourself with the current world.

      (define get-all-manual-keywords
        (let ([words #f])
          (λ ()
            (unless words
              (set! words (text:get-completions/manuals #f)))
            words)))


hth,
Robby

On Wed, Jul 2, 2008 at 8:12 AM, Robert Matovinovic
<robert.matovinovic at web.de> wrote:
> Hi,
> I stripped my files as much as possible to give you an insight in some
> specifics on one hand and keep them short on the other.
>
> You get three files
> info.ss:
> Just normal info file for compiling the collection
>
> mytest-plk-elk.ss:
> Stripped file with language definitions, it has a dummy command
> (mytest-command args) with arbitrary number of args and prints them in a
> list
>
> mytest-tool.ss:
> Tools file where somehow the error/s are in, writing it I took the
> frtime-tool.ss as kind of template.
>
> For testing you can put them into a folder and compile. If you have any
> further questions, just mail.
>
> I don't include any scribble files because I know that all commands are
> shown in PrettyBig, so it is not them.
>
> Concerning debugging I know now that it has something to do with my
> execute-callback. This I took from the original DrScheme callback in
> drscheme/private/unit.ss and tailored it to my needs. I omitted what didn't
> seem necessary, but I have thrown out an important part obviously. This was
> mainly because I always got the error messages as I get them now like
>
> mytest-tool.ss:60:16: expand: unbound variable in module in:
> drscheme:language-configuration/internal:get-all-manual-keywords
>
> I commented out the part that caused the error message. The execute-callback
> mainly does two things apart from the original: 1. It can capture a
> selection of definitions-text for only evaluating that selection instead of
> the whole definitions window. 2. It wraps the definitions-text with commands
> for making a dde connection to the external program before evaluation. I
> substituted them just with print commands.
>
> Thanks for your time spending
>
> Robert
>
>
>
>
>
> -----Ursprüngliche Nachricht-----
> Von: robby.findler at gmail.com [mailto:robby.findler at gmail.com] Im Auftrag von
> Robby Findler
> Gesendet: Dienstag, 1. Juli 2008 22:40
> An: Robert Matovinovic
> Betreff: Re: [plt-scheme] word completion for module based languages
>
>
> Sleep well. :)
>
> On Tue, Jul 1, 2008 at 3:41 PM, Robert Matovinovic
> <robert.matovinovic at web.de> wrote:
>> Thank you very much for your offer. I will send you some small files
>> that should do it, but not before tomorrow, it's 22:45 here. Robert
>>
>> -----Ursprüngliche Nachricht-----
>> Von: robby.findler at gmail.com [mailto:robby.findler at gmail.com] Im
>> Auftrag von Robby Findler
>> Gesendet: Dienstag, 1. Juli 2008 18:18
>> An: Robert Matovinovic
>> Cc: plt-scheme at list.cs.brown.edu
>> Betreff: Re: [plt-scheme] word completion for module based languages
>>
>>
>> Hm. I think you're right, which means that its hard for me to tell
>> what is going wrong without some more details. If you have the time,
>> would you mind sending me a cut down version of your tool that
>> illustrates the problem, but hopefully is just a couple of small
>> files?
>>
>> (Probably there is a bug...)
>>
>> Thanks,
>> Robby
>>
>> On Tue, Jul 1, 2008 at 11:15 AM, Robert Matovinovic
>> <robert.matovinovic at web.de> wrote:
>>> as I already mentioned in the last mail, which unfortunately wasn't
>>> sent to the list, my language is not augmenting the capability-value
>>> method. I read docs, looked in the source, tried different things,
>>> the whole day but didn't come to a solution. Concerning the
>>> capability-value example below I must make a stupid mistake, because
>>> whereever I put it in my code I get
>>>
>>> expand: unbound variable in module in:
>>> drscheme:language-configuration/internal:get-all-manual-keywords
>>>
>>> Well, I looked up in private/drsig.ss that get-all-manual-keywords is
>>> a method of drscheme:language-configuration/internal since I thought
>>> this might be the mistake because
>>> drscheme:language-configuration:get-all-manual-keywords brought up
>>> the respective mistake. So what I'm doing wrong?
>>>
>>> On the other hand I found that 'drscheme:autocomplete-words is #t.
>>> Also it seems to me get-all-manual-keywords is the default for
>>> 'drscheme:autocomplete-words is #t. So it should just work without
>>> augmenting capability-value. Is that true? In my language "no
>>> completions available .." is the only thing I see.
>>>
>>> 'gui-debugger:debug-button is also #t. I defined the method
>>> debugger:supported? in the
>>> drscheme:language:module-based-language->language-mixin of my
>>> language. The button is there and clickable not depending on my
>>> debugger:supported? method. But after clicking the debugger panels
>>> don't show up although in the background something happens. If I want
>>> to debug (+ 1 2) after some time the interaction window opens and
>>> displays the result. The debugger:supported? method seems also to be
>>> set to #t by default. But something suppresses the debugging.
>>>
>>> Any help appreciated.
>>> Robert
>>>
>>>
>>>
>>> -----Ursprüngliche Nachricht-----
>>> Von: plt-scheme-bounces at list.cs.brown.edu
>>> [mailto:plt-scheme-bounces at list.cs.brown.edu] Im Auftrag von Robby
>>> Findler
>>> Gesendet: Dienstag, 1. Juli 2008 05:02
>>> An: Robert Matovinovic
>>> Cc: plt-scheme at list.cs.brown.edu
>>> Betreff: Re: [plt-scheme] word completion for module based languages
>>>
>>>
>>> [ Matthew? Greg? A debugger question below. ]
>>>
>>> Is your language augmenting the capability-value method? Perhaps you
>>> need something like this:
>>>
>>>      (define/augment (capability-value key)
>>>        (cond
>>>          [(eq? key 'drscheme:autocomplete-words)
>>>           (drscheme:language-configuration:get-all-manual-keywords)]
>>>          [else (drscheme:language:get-capability-default key)]))
>>>
>>> You might want to check over the docs for
>>>
>>>  drscheme:language:register-capability
>>>
>>> to see if there are other capabilities you want to enable.
>>>
>>> For the debugger, it looks like you want to both respond with #t to
>>> the 'gui-debugger:debug-button capability (add to the above method),
>>> and define the debugger:supported? method, which should also return
>>> #t. I'm just inferring that from the source, tho, so Matthew or Greg
>>> may know better.
>>>
>>> Robby
>>>
>>> On Sat, Jun 28, 2008 at 2:20 AM, Robert Matovinovic
>>> <robert.matovinovic at web.de> wrote:
>>>> Yes, the language is in the language dialog and defined as module
>>>> with "(module ..." and uses
>>>> drscheme:language-configuration:add-language
>>>> and drscheme:get/extend:extend-unit-frame. I will look at "#lang
>>>> ...". So far I only know that one can use it as an abbreviation for
>>>> module.
>>>>
>>>> Robert
>>>>
>>>> -----Ursprüngliche Nachricht-----
>>>> Von: robby.findler at gmail.com [mailto:robby.findler at gmail.com] Im
>>>> Auftrag von Robby Findler
>>>> Gesendet: Freitag, 27. Juni 2008 22:16
>>>> An: Robert Matovinovic
>>>> Cc: plt-scheme at list.cs.brown.edu
>>>> Betreff: Re: [plt-scheme] word completion for module based languages
>>>>
>>>>
>>>> On Fri, Jun 27, 2008 at 2:47 PM, Robert Matovinovic
>>>> <robert.matovinovic at web.de> wrote:
>>>>> Finally I could test what you have checked in, Robby. Word
>>>>> completion now shows also all commands of my module language in
>>>>> version 4.0.1 [3m](Yippieh), thank you very much. But unfortunately
>>>>> it works only if one of the built-in languages are chosen but not
>>>>> when I switch to my module language. So something is still missing
>>>>> which is important to me. Maybe there is something I have to add to
>>>>> my module. I don't ask for language specific filtering of the word
>>>>> completion, the whole list would be alright, just that it works
>>>>> also with a module language.
>>>>
>>>> Can you tell me a little more about how you've added the language to
>>>> DrScheme? Is it in the language dialog?
>>>>
>>>> If so, perhaps you might consider defining your language in a way
>>>> that "#lang ..." works and then using DrScheme's module language.
>>>> We're trying to migrate that way so that all of the information
>>>> needed to run the program is in the program's text itself (as
>>>> opposed to being in the environment).
>>>>
>>>>> I also like to use the debugger with my module language, but it
>>>>> doesn't. Is there an easy fix?
>>>>
>>>> I suspect the answer here may be the same as the above, but I'm not
>>>> sure.
>>>>
>>>> Robby
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>>
>

Posted on the users mailing list.