jesse697
2021-11-2 07:00:43

running resyntax in a GitHub Action (headless Linux install) flames out because we need GTK?! :eyes:


laurent.orseau
2021-11-2 07:13:50

cc @notjack :point_up:


jesse697
2021-11-2 09:07:30

btw the screenshot is not ideal — it appears that export PATH=... alone is causing the problem. What you don’t see is that the next line is a call to resyntax analyze --directory dir-name-here


soegaard2
2021-11-2 11:06:16

Use xvfb to run it



sorawee
2021-11-2 11:11:35

But why does it need GUI? It’s a code transformation tool, no?


sorawee
2021-11-2 11:12:22

sorawee
2021-11-2 11:13:50

Well, all I can say is that fmt doesn’t require GUI, and probably could be used as a drop-in replacement for framework’s indenter.


samdphillips
2021-11-2 18:09:01

Is there a way to preserve the newlines in fmt?

I’m experimenting with plugging it into resyntax.


sorawee
2021-11-2 18:11:14

See https://github.com/sorawee/fmt/issues/20. Preserving newlines kinda defeats the purpose of code formatting (in the traditional sense where you want code to stay within the page width limit).


sorawee
2021-11-2 18:12:11

It does preserve consecutive newlines where number of newlines > 1, though, since that’s usually intentional.


samdphillips
2021-11-2 18:21:41

I can’t speak for @notjack but in the current state it looks like resyntax wants to maintain the programs newlines and is more concerned with the indentation of those lines.


samdphillips
2021-11-2 18:24:24

So with framework it would format like this: The define form supports a shorthand for defining functions (including function-returning functions). 3 (define err 4 (lambda (s) 5 (cons 'err s))) 3 (define (err s) 4 (cons 'err s)) Using fmt the output (in the second chunk there) the code is all on one line.


samdphillips
2021-11-2 18:24:47

This may not be a great example. I have another which has lets in it.


samdphillips
2021-11-2 18:25:34

Reading the issue now …


sorawee
2021-11-2 18:25:37

Right. The decision to only indent code could be intentional. But it could also be an artifact since earlier code formatters don’t handle comments, and only code indenters do, so there were not many choices.


greg
2021-11-2 18:50:50

Probably dumb question/idea: What if fmt (and/or pprint-compact) added the concept of a hard line break (similar to CTRL+ENTER in some word processors or an HTML <br> element). And then what if there were some read option that preserves newlines as hard breaks. Would that make fmt act as an indenter-only?


greg
2021-11-2 18:51:16

(I’ve only glanced at your code quickly/shallowly so no idea if this even makes sense.)


capfredf
2021-11-2 19:52:26

is there an equivalent to python3 -m http.server in Racket?


gmauer
2021-11-2 19:53:18

As in a way to load in a module on start or as in a way to start a simple static file web server?


gknauth
2021-11-2 19:54:04

Yes, I’m just looking for the specific incantation. I’m sure others will jump in with the exact answer soon if I don’t.


ben.knoble
2021-11-2 19:57:46

Loading in a module is one of many flags (-l, -t, -e, -p come to mind). I would have to go digging for the static web server; not an area I’m familiar with


gmauer
2021-11-2 19:58:38

I know this https://docs.racket-lang.org/web-server/run.html#%28def._%28%28lib._web-server%2Finsta%2Finsta..rkt%29._static-files-path%29%29

I’m 70% sure that I’ve done it before from the cli like you are doing there though


ben.knoble
2021-11-2 19:58:53

e.g., my slack archive viewer is run with racket -l slack-archive-viewer


samdphillips
2021-11-2 20:01:20

I’ve wanted to make a raco webserver (or some such name) to do the same as that python to just serve some static files, but I’ve been to lazy to work it out.



ben.knoble
2021-11-2 20:03:24

But I can’t tell because while both hang, neither tells me what port anything is happening on


samdphillips
2021-11-2 20:05:53

I think those both just serve a servlet module though?


ben.knoble
2021-11-2 20:06:29

Ok, not plt-web-server ; I think you’re right @samdphillips. I finally found this after passing the port explicitly.


samdphillips
2021-11-2 20:06:34

python -m http.server serves whatever static files are in the current working directory.


ben.knoble
2021-11-2 20:21:37

This behemoth serves static file, but has no directory listing: racket -l racket/base -l web-server/servlet -l web-server/servlet-env -e '(serve/servlet (lambda _ (response/xexpr (list (string->symbol "html")))) #:extra-files-paths (list ".") #:servlet-path "")' (I hopped some hoops to avoid using quotes, since quotes-in-quotes are annoying in the shell. But yeah, this could be made easier, and add the directory listing at the same time.)


sorawee
2021-11-2 20:26:28

I can put that on a wishlist. There’s no technical difficulty to preserve newlines. Right now, newlines are explicitly stripped away. So to preserve them, it only requires removing the code to strip the newlines.

The challenging paer is that the formatting combinators assume an invariant that these newlines are stripped away. Without this invariant, formatting doesn’t work properly. I will try to see what I can do to relax this restriction, but it’s not my priority.


joel
2021-11-2 20:31:52

Every once in a while the package server still gets in this state where it’s looking for the master branch on my package’s github repo (which uses main instead) which causes the build to fail. (https://pkgd.racket-lang.org/pkgn/search?q=splitflap) git: could not find requested reference reference: master repo: otherjoel/splitflap.git


joel
2021-11-2 20:33:16

The package sources in question are all set to, e.g. <https://github.com/otherjoel/splitflap.git?path=splitflap#main>


mflatt
2021-11-2 20:40:05

The problem is on the client side, and it’s fixed for the upcoming v8.3 release.


samdphillips
2021-11-2 20:48:31

Ok I stole it and made a raco command. I’ll put it on the pkg server in a few https://github.com/samdphillips/raco-static-web



ben.knoble
2021-11-2 21:01:47

Lol nice. I’m trying to hack the files listing in, but that’s somehow proving harder (or I’m making it to complicated)


samdphillips
2021-11-2 21:02:48

I think that’s where I gave up last time I looked at this. I think there is builtin servlet that can do it, but you have to do a little bit extra to make it work.


notjack
2021-11-2 21:31:54

notjack
2021-11-2 21:33:51

Resyntax tries very hard to preserve the formatting of the existing code as much as possible. What I would need from fmt is the ability to format a syntax object only partially. Specifically, I want to format a syntax object but preserve the formatting of any syntax-original? subforms inside the syntax object, so that only the indentation of those forms are changed.


ben.knoble
2021-11-2 21:58:35

I have an improved version… could still use to take command-line args like http.server, but I need to stop for now.


blerner
2021-11-2 22:51:45

Quick scribble question: How do I create a @tech link to the KeyEvent definition in 2htdp/universe?


samdphillips
2021-11-2 22:53:49

I’ll take a look in a bit. I added a README and gave you credits.


mflatt
2021-11-2 22:55:18

@tech[#:doc '(lib "teachpack/teachpack.scrbl")]{KeyEvent}


blerner
2021-11-2 22:57:09

Thanks — that takes me to the docs from htdp/world, though (i.e., teachpack/world.html#(tech._keyevent))


blerner
2021-11-2 22:58:53

but if I try #:doc '(lib "teachpack/2htdp/scribblings/universe.scrbl"), it complains that the tag is undefined


greg
2021-11-2 23:04:26

@sorawee Of course, please don’t even bother adding to a wishlist if it would be awkward, square-peg/round-hole! (I thought maybe at the level of pprint-compact that v-append or something like it could handle hard breaks…? But I don’t really understand how that all works.)


greg
2021-11-2 23:08:12

An indenter (not full reformatter) for say racket-lang is not terribly difficult — assuming something has already tokenized (or at least done some char classification as does Emacs), and you have a few handy functions for things like next/prev/up/down sexp. I think that’s the aspect that can come either from framework (which is kind of heavy if that’s all one needs from it), or from module-lexer plus writing some of those “sexp nav” functions.


blerner
2021-11-2 23:37:33

ok, for future reference, it’s @tech[#:doc '(lib "teachpack/teachpack.scrbl") #:tag-prefixes '("2htdp" "world")]{KeyEvent} — I have zero clue why that works, but it does…


mflatt
2021-11-3 03:23:56

Oh, I see. I’s because the 2htdp documentation uses an explicit layer of tagging, which lets it define some of the the same terms in different ways within different sections. That’s not typical.