Closed djha-skin closed 2 years ago
I appreciate your patience with this rather odd pull request, it's my first one in the common lisp realm.
I added emit-pretty-as-document-to-string
and emit-pretty-as-document
, which allow to emit a yaml document that has lots of whitespace in it, so to speak.
Some notes:
generic-comparability
and replaced it with cdr-8
, again, to get the tests to pass. Let me know if you want to have this changed backed out, too.Again, thanks for humoring me :)
Thanks! Is this ready to review and merge, or do you want to apply further changes?
This is ready to merge now. Sorry about all that. tests didn't pass because of symbol interning reasons, I had to pull the macro out. They pass now :) Thanks for the patience, all done.
I don't know, maybe I'm just dumb. I can get the tests to pass, but I can't get the function to work outside the package. When I run
(yaml:with-emitter-to-string (em) (yaml:emit-pretty-as-document em "foo"))
I invariably get
* (cl-yaml:with-emitter-to-string (em) (cl-yaml:emit-pretty-as-document em "foo"))
debugger invoked on a UNDEFINED-FUNCTION @52A00674 in thread
#<THREAD "main thread" RUNNING {1001088113}>:
The function YAML.EMITTER::EM is undefined.
Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.
restarts (invokable by number or by possibly-abbreviated name):
0: [CONTINUE ] Retry calling YAML.EMITTER::EM.
1: [USE-VALUE ] Call specified function.
2: [RETURN-VALUE ] Return specified values.
3: [RETURN-NOTHING] Return zero values.
4: [ABORT ] Exit debugger, returning to top level.
("undefined function")
Like, what am I doing wrong? It works when I define it in-package, it works in the tests, just not in my foreign function thing.
That did it!
Okay so the problem was that I am a clojurist and used to clojure things. In common lisp, where you define a function matters. I needed to define the function after the macros it was using.
I was able to commit this change, import it into my downstream project, and it worked!
This also explains why I got the tests to pass: I ran the emitter package through the REPL a few times, so that when I redefined the .document...
function, it was defined properly in terms of macros that it already saw.
So I can definitively say it works now, because I was able to import it downstream and use it off the bat without any REPL redefinings.
:D Hope you're convinced, sorry. Newbie :D
Just tested it again today, still works :+1:
Thanks!
These functions use the libyaml emitter stuff to sort of "pretty print" the YAML using default settings.