sschwarzer
2022-7-22 10:56:29

In a Scribble document, is there a way to query the absolute file path of the corresponding .scrbl file?


sschwarzer
2022-7-22 10:57:32

I realize this might be tricky if a document includes other documents. In my case it’s all in one document, though.


sschwarzer
2022-7-22 11:03:21

Background of the question: I want to include images with image, but ideally I’d like the paths to be independent of the current directory when I start raco setup. I put the image files in the same directory as the Scribble file.


sschwarzer
2022-7-22 11:05:39

Depending on the current directory is kind of ok for me locally, but will that also work when the document is built on the package server, i.e. is the then-current directory also the parent path of scribblings?


mflatt
2022-7-22 11:57:54

I think you want define-runtime-path. See the section for the racket/runtime-path module for an overview.


greg
2022-7-22 14:40:56

Instrumenting for coverage only happens if you use a C-u prefix for the racket-test command, so just don’t use that prefix?



greg
2022-7-22 14:43:39

I’m not certain what you mean by error traces. For the run commands in general, racket-error-context controls whether it gets errortrace style instrumentation to have more details for error message “Context:” displays.



greg
2022-7-22 14:44:57

If you mean something else by “error traces” please let me know?


sschwarzer
2022-7-22 14:52:46

Thank you! I had seen and followed the link to define-runtime-path from the image description, but gave up on understanding the documentation after reading the first one and a half paragraphs. :confused:

I’ve now defined (define-runtime-path scribblings-directory ".") and hope it’ll work. :slightly_smiling_face:


sschwarzer
2022-7-22 14:58:28

Something that still confuses me:

I had added a @displayln[scribblings-directory] after the above definition and when I ran raco setup, the absolute path was printed, so that looks ok. However, when I run raco setup after that, it doesn’t print the path again.

I thought it may be that after creating the zo files under the compiled directories, Racket might not recompile the Scribble file. But even after removing the compiled directories under my Git root, the path isn’t printed. It’s only printed again if I change and save the scrbl file. (Saving alone isn’t enough.) What’s going on here? :slightly_smiling_face:


mflatt
2022-7-22 15:55:26

I forget how things go exactly, but I think raco setup intercepts output to current-output-port and/or current-error-port, and maybe more so with parallel builds than sequential builds.

In general, because output capture is used for various purposes, find that it works better to use logging for debugging output. For example, I’d write @log-error["~a" scribblings-directory]. It’s not an error, of course, but I use log-error because error-level messages are printed by default.


capfredf
2022-7-22 16:04:24

I wasn’t clear. It looks to me that the c-u prefix for racket-test adds both instrumenting for coverage and better stack trace. I was asking if there is a config to toggle off showing coverage, i.e. make the c-u prefix for racket-test behave the same way it does for other commands, such as racket-run-module-at-point


sschwarzer
2022-7-22 16:43:57

Is (or value other-value) in place of (if value value other-value) idiomatic Racket? Or would you just use the if form because it’s presumably clearer (apart from the repetition of value)?


sorawee
2022-7-22 16:45:02

It’s idiomatic, though I wish it’s not.


sschwarzer
2022-7-22 16:45:58

I get your point. :slightly_smiling_face: Do you use something else than the two approaches or would you just use if as shown?


sorawee
2022-7-22 16:46:50

I do use or in Racket, because I think being more idiomatic is more important.


sorawee
2022-7-22 16:48:28

But if I can re-imagine things, I would restrict or for testing, and introduce a new operation for getting “default values”


pavpanchekha
2022-7-22 17:41:58

I know @samth asked for it a while back, so I wrote a blog post about some optimization work I did for Herbie a few weeks ago: https://pavpanchekha.com/blog/optimizing-alt-minimize.html


pavpanchekha
2022-7-22 17:42:13

It does have some of the dead ends edited out.


sorawee
2022-7-22 17:47:08

Not sure if this is a typo:

> which leads to a big speed-up, taking us from 49 seconds to about 48 seconds. That doesn’t look like a big speed-up to me


pavpanchekha
2022-7-22 17:52:36

lol


pavpanchekha
2022-7-22 17:52:39

will fix


pavpanchekha
2022-7-22 17:54:26

I do actually think that the real lever that helped me do the optimization is the little GUI profile explorer I wrote, which itself can really credit Racket’s quite good profile library, which makes it easy to work with profiles.


greg
2022-7-22 18:45:37

Ah OK I understand now.


greg
2022-7-22 18:46:15

There’s no such option for racket-test now.


greg
2022-7-22 18:47:10

But keep in mind that plain racket-test (without the coverage stuff) is effectively the same as doing racket-run-module-at-point with point inside some test submodule. And you could use C-u with that (to get the better errortrace context).


greg
2022-7-22 18:49:04

So that would be my suggested hack or work-around, until/unless racket-test gets some enhancement. idk, maybe plain racket-test should just do the errortrace context automatically, as if it set racket-error-context to 'high temporarily. I don’t see a downside; assuming that’s OK that would be straightforward.



spdegabrielle
2022-7-22 20:08:58


soegaard2
2022-7-22 21:01:32

Btw - the trick only works for non-booleans.


laurent.orseau
2022-7-22 21:12:27

Thanks everyone


laurent.orseau
2022-7-22 21:17:42

laurent.orseau
2022-7-22 21:47:16

Seems like going the pasteboard way will be easier, even though I quite like the note style of DrRacket. Here’s a gist demonstrating how to go back and forth between the zooming feature and some other overlay: https://gist.github.com/Metaxal/cef7a4a2372aa5b19ddc5c9841cfaaff


jcoo092
2022-7-22 23:42:32

Scribble gets a semi-positive mention here: https://buttondown.email/hillelwayne/archive/on-metafiles/