Is there something wrong with the nrepl.middleware.print/print printer when it comes to lazy output? 🧵
Thanks for having a look! https://github.com/clojure-emacs/cider-nrepl/issues/903 Let me know if I can improve the issue report.
BTW: I can reproduce the issue, but I'm not sure yet what's causing it. Most likely it's pprint overriding *out* at the wrong time. I couldn't find the exact place in my initial investigation. Could you please create a ticket on cider-nrepl repo so that this is not lost?
When I evaluate:
(for [[type amount] {:wood 2 :iron 2}]
(println "\n--------\n" (str type " " amount)))
I get back the result "\n--------\n :wood 2\n(nil\n--------\n :iron 2\n nil)"
Calva’s nrepl message log:
1727018467380 -> sent
{
id: '124',
op: 'eval',
ns: 'mini.playground',
session: 'bd20ade5-ce08-42c1-91d4-cfd96548d22b',
code: '(for [[type amount] {:wood 2 :iron 2}]\n' +
' (println "\\n--------\\n" (str type " " amount)))',
'nrepl.middleware.print/options': { 'right-margin': 120, length: 200 },
'nrepl.middleware.print/print': 'cider.nrepl.pprint/pprint',
file: '/Users/pez/Projects/teasers/src/mini/playground.clj',
line: 16,
column: 1,
pprint: true
}
1727018467399 <- received 19ms
{
id: '124',
ns: 'mini.playground',
session: 'bd20ade5-ce08-42c1-91d4-cfd96548d22b',
value: '\n--------\n :wood 2\n(nil\n--------\n :iron 2\n nil)'
}
1727018467399 <- received 0ms
{
id: '124',
session: 'bd20ade5-ce08-42c1-91d4-cfd96548d22b',
status: [ 'done' ]
}Evaluating this using the cider.nrepl.pprint/pr printer, I get (nil nil) as result, as expected. Message log:
1727018716906 -> sent
{
id: '130',
op: 'eval',
ns: 'mini.playground',
session: 'bd20ade5-ce08-42c1-91d4-cfd96548d22b',
code: '(for [[type amount] {:wood 2 :iron 2}]\n' +
' (println "\\n--------\\n" (str type " " amount)))',
'nrepl.middleware.print/options': { '120': 120 },
'nrepl.middleware.print/print': 'cider.nrepl.pprint/pr',
file: '/Users/pez/Projects/teasers/src/mini/playground.clj',
line: 16,
column: 1,
pprint: true
}
1727018716929 <- received 23ms
{
id: '130',
out: '\n--------\n :wood 2\n',
session: 'bd20ade5-ce08-42c1-91d4-cfd96548d22b'
}
1727018716930 <- received 1ms
{
id: '130',
out: '\n--------\n :iron 2\n',
session: 'bd20ade5-ce08-42c1-91d4-cfd96548d22b'
}
1727018716931 <- received 1ms
{
id: '130',
ns: 'mini.playground',
session: 'bd20ade5-ce08-42c1-91d4-cfd96548d22b',
value: '(nil nil)'
}
1727018716931 <- received 0ms
{
id: '130',
session: 'bd20ade5-ce08-42c1-91d4-cfd96548d22b',
status: [ 'done' ]
}