armedbear / abcl

Armed Bear Common Lisp <git+https://github.com/armedbear/abcl/> <--> <svn+https://abcl.org/svn> Bridge
https://abcl.org#rdfs:seeAlso<https://gitlab.common-lisp.net/abcl/abcl>
Other
288 stars 29 forks source link

Add gray-streams:stream-line-length extension #639

Closed yitzchak closed 9 months ago

yitzchak commented 9 months ago

Add support for stream-line-length. This allows streams to override *default-line-length*. *print-right-margin* still takes precedence. Currently supported by Clasp, CMUCL, Mezzano, Lispworks, and SBCL. A PR for ECL is currently open. In the case of the open source implementations this extension originally came from CMUCL.

Example of usage:

CL-USER(1): (require :gray-streams)
("GRAY-STREAMS")
CL-USER(2): (defclass fu (gray-streams:fundamental-character-output-stream) ())

#<STANDARD-CLASS FU {64CCBA30}>
CL-USER(3): (defmethod gray-streams:stream-write-char ((s fu) ch) (write-char ch))

#<STANDARD-METHOD GRAY-STREAMS:STREAM-WRITE-CHAR (FU T) {7EA784ED}>
CL-USER(4): (defmethod gray-streams:stream-line-length ((s fu)) 15)

#<STANDARD-METHOD GRAY-STREAMS:STREAM-LINE-LENGTH (FU) {1991B199}>
CL-USER(5): (pprint '(defun wibble (bar quux &optional zip) (format t "hello ~a ~a ~a~%" bar quux zip)))

(DEFUN WIBBLE (BAR QUUX &OPTIONAL ZIP)
  (FORMAT T "hello ~a ~a ~a~%" BAR QUUX ZIP))
CL-USER(6): (pprint '(defun wibble (bar quux &optional zip) (format t "hello ~a ~a ~a~%" bar quux zip)) (make-instance 'fu))

(DEFUN WIBBLE (BAR
               QUUX
               &OPTIONAL
               ZIP)
  (FORMAT T
          "hello ~a ~a ~a~%"
          BAR
          QUUX
          ZIP))