Tools and Syntax Highlighting

59 views
Skip to first unread message

Ben Ryjikov

unread,
Jan 3, 2021, 7:32:33 PM1/3/21
to racket...@googlegroups.com, tbne...@gmail.com
Hi Racket,

Is it possible for a tool invoked by info.rkt to access code which is outside of the tool?

We’re building a #lang and would like to have on-demand syntax highlighting.
We’ve tried using a tool, and have successfully made a button and a menu item that do it, but we’d like to activate the highlighting programmatically at runtime instead of by clicking on something.
We also are hoping to have multiple highlights at once if possible.

Is there any way to get on-demand syntax highlighting without using a button or menu item? Are there any pre-existing Racket tools or functions that would do this?

Thanks for your time and Happy New Year!

Best,
Ben

Stephen De Gabrielle

unread,
Jan 4, 2021, 9:05:11 AM1/4/21
to Ben Ryjikov, racket...@googlegroups.com, tbne...@gmail.com
I think datalog does this;

image.png


 

Thanks for your time and Happy New Year!

Best,
Ben

--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/BA1B6C4F-8172-462F-9E2D-8F6F2A9C6BB4%40gmail.com.

Ben Ryjikov

unread,
Jan 4, 2021, 2:46:30 PM1/4/21
to Stephen De Gabrielle, racket...@googlegroups.com, tbne...@gmail.com
I’m sorry - I didn’t explain what kind of highlighting we’re looking for.

We’re building a new #lang, and we want it so that sometimes when you run, DrRacket highlights a part of the program you are running. But we only want that in certain situations, so we want to create a function which we can call that would do the highlighting on demand.

Are there any functions or libraries which can do that?

We’ve managed to get highlighting through a tool (which is listed in info.rkt), but we’re struggling to get it on demand because we can’t easily find a way for the tool and the program to share code.

Is there a way for a tool to access code which outside of the tool at runtime?

-Ben

On Jan 4, 2021, at 9:04 AM, Stephen De Gabrielle <spdega...@gmail.com> wrote:

On Mon, Jan 4, 2021 at 12:32 AM Ben Ryjikov <bryj...@gmail.com> wrote:
Hi Racket,

Is it possible for a tool invoked by info.rkt to access code which is outside of the tool?

We’re building a #lang and would like to have on-demand syntax highlighting.
We’ve tried using a tool, and have successfully made a button and a menu item that do it, but we’d like to activate the highlighting programmatically at runtime instead of by clicking on something.
We also are hoping to have multiple highlights at once if possible.

Is there any way to get on-demand syntax highlighting without using a button or menu item? Are there any pre-existing Racket tools or functions that would do this?

I think datalog does this;

<image.png>

Stephen De Gabrielle

unread,
Jan 4, 2021, 5:02:30 PM1/4/21
to Ben Ryjikov, racket...@googlegroups.com, tbne...@gmail.com

Sorry I'm not good at this - some guesses below. HTH

On Mon, Jan 4, 2021 at 7:46 PM Ben Ryjikov <bryj...@gmail.com> wrote:
I’m sorry - I didn’t explain what kind of highlighting we’re looking for.

We’re building a new #lang, and we want it so that sometimes when you run, DrRacket highlights a part of the program you are running.

The closest I can think of is debug that shows where you are up to as you step through the program. (the green triangle in the datalog screenshot below)
image.png
 
But we only want that in certain situations, so we want to create a function which we can call that would do the highlighting on demand.

Are there any functions or libraries which can do that?

We’ve managed to get highlighting through a tool (which is listed in info.rkt), but we’re struggling to get it on demand because we can’t easily find a way for the tool and the program to share code.

Is there a way for a tool to access code which outside of the tool at runtime?

Robby Findler

unread,
Jan 4, 2021, 8:12:13 PM1/4/21
to Ben Ryjikov, Stephen De Gabrielle, Racket Users, Tim Nelson
I think a good first question here is "what do you want to happen when you are running the program from outside DrRacket?". DrRacket is, in a general sense, designed to reflect extra information about how a program runs when it can glean that information, but it isn't meant to be the only way that Racket programs run, merely one of them. So what you want to think about is: how can a program offer up information about itself (and what APIs/values/data should that be)? and then: how can DrRacket (or other things that run Racket programs, eg Racket Mode, or command-line racket or a standalone executable, etc) get a hold of that information to show it in a meaningful way?

There are some examples of success following generally this pattern: test coverage is a means whereby a program is expanded, then instrumented by some tool (via rewriting the program) such that the instrumented program produces information about what parts of the program actually ran to its context (which might be DrRacket but might also be the "cover" library). Check Syntax (which runs automatically these days) expands the program and records information about it (notably binding and bound occurrences of variables) and then DrRacket and Emacs Mode let you work with that information. 

Robby



Ben Ryjikov

unread,
Jan 6, 2021, 3:10:11 AM1/6/21
to Robby Findler, Stephen De Gabrielle, Racket Users, Tim Nelson
Hi Robby and Stephen,

Thanks for your suggestions! It’s working now thanks to a mix of rackunit tools and dynamic require.
We’re also thinking about how to make our code less reliant on DrRacket.

Best,
Ben

Stephen De Gabrielle

unread,
Jan 6, 2021, 7:35:58 AM1/6/21
to Ben Ryjikov, Robby Findler, Racket Users, Tim Nelson
Glad to hear it! 
Reply all
Reply to author
Forward
0 new messages