That is indeed how. But now that looked at the pollen docs, I see the issue. It looks like you have to be able to run the config submodule of some program to be able to figure out how to syntax color it? That's not generally something that is well-supported, although I suppose you could make it work. There are some dicey questions, tho, like what if the config submodule has a definition like this:
#lang racket/base (define (tuesday?) (= (date-week-day (second->date (current-seconds))) 2)) (define command-char (if (tuesday?) #\◊ #\☺)) Then if I compiled a file on tueday and ran it on wednesday things wouldn't really be doing the right thing. The usual way we deal with configuration at that level would be to allow someone to write, say. #lang pollen command-char ☺ and, as long as the "command-char" declaration appears on the first line, then the pollen reader would respect it and change the command-char. And one could, without too much trouble, define "#lang spollen" that was a shorthand for "#lang pollen command-char ☺". (If that all seems reasonable, then my original reply would apply.) Robby On Fri, Nov 27, 2015 at 3:42 PM, <m...@mbtype.com> wrote: > Sorry for the noob question, but broadly, how does one affect the behavior of > the syntax colorer (and thereby the lexer) from the #lang (if not through > `get-info`)? > > > On Friday, November 27, 2015 at 8:37:47 AM UTC-8, Robby Findler wrote: >> I think that you have to make the syntax colorer discover which is the >> @ character in the same way "#lang pollen" discovers it and then pass >> that along to the scribble-inside-lexer. (This may require changing >> scribble-inside-lexer to be more flexible in when it accepts the >> character.) Lexers have a way to track context information (via the >> "mode" argument and the last result) and so that can be extended to >> track whether or not the character has been seen yet and, if it has, >> what it is. >> >> Robby >> >> >> On Fri, Nov 27, 2015 at 10:09 AM, MB wrote: >> > In `#lang pollen`, which uses a variant of at-expressions, you can change >> > the command character on a per-source-file basis, so you can say `◊(+ 1 >> > 1)` or `∆(+ 1 1)` or `@(+ 1 1)` ... >> > >> > I'm trying to figure out if I can bubble this up to DrRacket for syntax >> > coloring. I see two wrinkles: >> > >> > 1) For syntax-coloring purposes, the command character is set in the >> > `get-info` function for the #lang, which in pollen looks like this: >> > >> > (define (get-info in mod line col pos) >> > (λ (key default) >> > (case key >> > [(color-lexer) >> > (define make-scribble-inside-lexer2 >> > (dynamic-require 'syntax-color/scribble-lexer >> > 'make-scribble-inside-lexer (λ () #f))) >> > (cond [make-scribble-inside-lexer2 >> > (make-scribble-inside-lexer2 #:command-char #\◊)] >> > [else default])] >> > [else default]))) >> > >> > >> > I could set the command character properly if I had access to the path of >> > the source file. But IIUC DrRacket invokes the `get-info` for a #lang on a >> > "global" basis, i.e., before it considers any source-specific information. >> > >> > >> > 2) DrRacket seems to cache the result of `get-info` for a whole session. >> > So even if I could set the command character correctly for the first >> > source file, it wouldn't change if I had multiple source files open with >> > multiple command characters (in different tabs or windows). > > -- > 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. -- 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.