1

I am working on improving the org babel racket mode and am running into issues with inserting longer vars

Whether I do

      (format "%S" '((2 0 0 4 2 0 0 3 0 0 4 0 0 7)))

or

      (with-output-to-string (princ '((2 0 0 4 2 0 0 3 0 0 4 0 0 7))))

I always get back the truncated

    ((2 0 0 4 2 0 0 3 0 0 ...))

not the full object in a string. How do I stringify the list without truncation?

3
  • It returns the full string for me. What Emacs version? Does it happen in emacs -q too?
    – choroba
    Jul 8 '20 at 23:06
  • @choroba 26.3 (9.0). It happens in org mode, in ielm and seemingly in my script. for emacs -q it does not truncate. I am doing spacemacs so I suppose its possibly something in there...though I would expect there to be a low level function where no such effect would occur Jul 8 '20 at 23:19
1

I suspect that the full value is returned, but you are being fooled by printing that elides part of the returned value. Try C-h v print-length, to see how to control such elision. If you don't believe that the returned value is correct (full length), apply function length to it, to see (to the list's car, in this case, or to the final string).

5
  • I thought of that, but this came up because I was getting that error from inside of a script, its not because I was playing around in the console. Just to verify I ran (length (format "%S" '((2 0 0 4 2 0 0 3 0 0 4 0 0 7)))) which gives me 27, but (length "((2 0 0 4 2 0 0 3 0 0 4 0 0 7))") is 31 - consistent with what I am seeing Jul 9 '20 at 0:17
  • 1
    So what does C-h v print-length give you? I'm pretty sure @Drew is right: (let ((print-length nil)) (length (format "%S" l))) returns 31 whereas (let ((print-length 10)) (length (format "%S" l))) returns 27. I bet your print-length is 10.
    – NickD
    Jul 9 '20 at 3:05
  • Oh I see, that was it! I had assumed that the truncation was happening in the stream, but I guess it must be inside princ? I looked in the docs on that and it didn't mention anything about this variable... Jul 9 '20 at 3:27
  • 1
    It's very low-level, defined in C code (src/print.c) and documented here. But its default value is nil, so why was yours set to 10?
    – NickD
    Jul 9 '20 at 3:55
  • Ah, I was looking at the princ docs. Good question though @NickD I am using spacemacs so it could come from there or from some plugin, is there a good way to check? Jul 9 '20 at 13:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.