- (let ((output (with-output-to-string (s)
- (write (cadr form) :stream s))))
- (unless (= (length output) 0)
- (when (and (eql (car form) 'backq-comma)
- (or (char= (char output 0) #\.)
- (char= (char output 0) #\@)))
- (write-char #\Space stream))
- (write-sequence output stream))))
+ ;;
+ ;; [...] above referred to the trick of printing to a string stream,
+ ;; and then simply printing the resulting sequence to the pretty
+ ;; stream, possibly with a space prepended. However, this doesn't
+ ;; work for pretty streams which need to do margin calculations. Oh
+ ;; well. It was good while it lasted. -- CSR, 2003-12-15
+ ;;
+ ;; This is an evil hack. If we print to a string and then print again,
+ ;; the circularity detection logic behaves as though it's already
+ ;; printed that data... and it has, to a string stream that we send
+ ;; to the bitbucket in the sky. -- PK, 2013-03-30
+ (when (eql (car form) 'backq-comma)
+ (let ((output (with-output-to-string (s)
+ ;; Patching evil with more evil. The next step is
+ ;; likely to stop the madness and unconditionally
+ ;; insert a space.
+ (let (*circularity-hash-table*
+ *circularity-counter*)
+ (write (cadr form) :stream s)))))
+ (when (and (plusp (length output))
+ (or (char= (char output 0) #\.)
+ (char= (char output 0) #\@)))
+ (write-char #\Space stream))))
+ (write (cadr form) :stream stream))