Any way to set preferences programmatically?

I had an epiphany recently. There are things I want students to have set up whenever they're working on my assignments.

  • I love using signatures, but need to include the Image signature and related if I want to do image or universe stuff.
  • I want to include some simple definitions. For example, I define \varepsilon to be a small number that students can use as the allowed delta in check-within.
  • I want coverage turned on.
  • I just found the Parenthesis color scheme setting that highlights nested expressions at different levels. (Thank you, JestArray, for showing that on your videos.)
  • I'd love for '() to displayed as empty until I introduce quote and ', assuming I ever do.

Getting all of these in the same state across computers, students, and environments can be a bit of a pain. One set can be done by require-ing a file. Another set requires detailed instructions about setting preferences.

Is there any API for setting preferences in the current running instance of DrRacket? If there were, I could do all of this in a required file, eventually turn it into a package, and keep it updated.

If there isn't, is such a thing even possible? Is it something people would be interested in? It would allow you to save preferred settings as a Racket script that you could run in a new environment. You could have differing preferences depending on what you're trying to do/which language you're working in.

I know the core team has way too much to do already, but this seemed like such a good idea that I wanted to share.

Use (find-system-path 'pref-file) to find the preferences file.
Then you need to look through to find the keys you need.

Welcome to Racket v8.12 [cs].
> (find-system-path 'pref-file) 
#<path:/Users/soegaard/Library/Preferences/org.racket-lang.prefs.rktd>

% head -5  /Users/soegaard/Library/Preferences/org.racket-lang.prefs.rktd
(
 (|plt:DrRacket 7.7-splash-max-width| 996)
 (|plt:DrRacket 7.7.0.4-splash-max-width| 996)
 (|plt:DrRacket 7.7.0.7-splash-max-width| 993)
 (plt:framework-pref:drracket:home/end-is-beginning/end-of-document #t)

Most settings are under drracket not DrRacket.

% grep drracket  /Users/soegaard/Library/Preferences/org.racket-lang.prefs.rktd | wc -l
     114
1 Like

Cool. But you can't set them this way, can you? You'd have to do a search and replace and rewrite the whole file?

Look at put-preferences and get-preferences.

1 Like

OMG. This is awesome. Thanks!

1 Like