[racket] read-language (was: How to associate a custom syntax color lexer with a new module language)
On Fri, Jun 22, 2012 at 1:27 PM, Stephen Chang <stchang at ccs.neu.edu> wrote:
>> FWIW, DrRacket calls read-language on a port containing the contents
>> of the definitions window. Probably the call you're interested in is
>> in drracket/private/module-language-tools.rkt. If you see exceptions
>> being swallowed there, then probably I coudl add some logging code to
>> help others avoid these problems in the future.
>
> Tangentially related question. I have a drracket (definitions-text)
> plugin that I only want active when the #lang is a specific language.
> Is read-language the proper thing to use for this?
Yes.
> Is there an example somewhere of using read-language for this purpose?
> I've been trying to figure out how to use the result from
> read-language but I'm having trouble understanding the docs and the
> examples I've found in collects only seem to test whether
> read-language succeeded or not.
The one I pointed to below uses the result, I believe.
Robby
>
>>
>> Robby
>>
>> On Fri, Jun 22, 2012 at 9:24 AM, Jens Axel Søgaard
>> <jensaxel at soegaard.net> wrote:
>>> That might be it. I thought that the get-info business avoided
>>> the need of an info.rkt file.
>>>
>>> Thanks,
>>> Jens Axel
>>>
>>>
>>> 2012/6/22 Robby Findler <robby at eecs.northwestern.edu>:
>>>> One thing that's easy to forget is to re-run 'raco setup' to register
>>>> the info.rkt's keys.
>>>>
>>>> Robby
>>>>
>>>> On Fri, Jun 22, 2012 at 9:08 AM, Danny Yoo <dyoo at hashcollision.org> wrote:
>>>>>> However it seems that DrRacket never calls the get-info function in question.
>>>>>> To check this, I added a displayln call to print a message each get-info
>>>>>> is called, and I never see any output from this.
>>>>>
>>>>> Odd; I'm seeing output! So I can't duplicate what you're seeing:
>>>>> DrRacket appears to be running the get-info function on my end.
>>>>>
>>>>> Here's what I'm seeing on the console when I try running on one of
>>>>> your test files "testing.rkt":
>>>>>
>>>>> ---
>>>>> kepler ~/work/bracket/bracket/lang $ drracket ../tests/testing.rkt
>>>>> (reader/get-info #<input-port> bracket/lang/reader #f #f 1)
>>>>> (reader/get-info drracket:toolbar-buttons #f)
>>>>> (reader/get-info drscheme:toolbar-buttons #f)
>>>>> (reader/get-info drracket:opt-out-toolbar-buttons ())
>>>>> (reader/get-info #<input-port> bracket/lang/reader #f #f 1)
>>>>> close
>>>>> close
>>>>> (reader/get-info #<input-port> bracket/lang/reader #f #f 1)
>>>>> (reader/get-info #<input-port> bracket/lang/reader 1 0 1)
>>>>> (reader/get-info color-lexer #f)
>>>>> exception in colorer thread: #(struct:exn:fail:contract:arity "context
>>>>> expected 1 value, received 5 values: \"\\n\" 'white-space #f
>>>>> #<position> #<position>" #<continuation-mark-set>)
>>>>>
>>>>> === context ===
>>>>> /home/dyoo/local/racket-5.2.1/lib/racket/collects/syntax-color/module-lexer.rkt:25:0:
>>>>> module-lexer
>>>>> /home/dyoo/local/racket-5.2.1/lib/racket/collects/framework/private/racket.rkt:1281:26
>>>>> /home/dyoo/local/racket-5.2.1/lib/racket/collects/framework/private/color.rkt:292:4:
>>>>> re-tokenize method in ...rk/private/color.rkt:66:2
>>>>> /home/dyoo/local/racket-5.2.1/lib/racket/collects/framework/private/color.rkt:455:17
>>>>> ____________________
>>>>> Racket Users list:
>>>>> http://lists.racket-lang.org/users
>>>
>>>
>>>
>>> --
>>> --
>>> Jens Axel Søgaard
>>
>> ____________________
>> Racket Users list:
>> http://lists.racket-lang.org/users