# HG changeset patch # User Richard Westhaver # Date 1716755664 14400 # Node ID fe7f583d8b02f462f9fd3a52da97ac88924967c6 # Parent 73c8c12979898da05622989d8466b78cc9ebab0c write-sxp-stream for sk-config diff -r 73c8c1297989 -r fe7f583d8b02 lisp/lib/skel/core/obj.lisp --- a/lisp/lib/skel/core/obj.lisp Sun May 26 16:02:37 2024 -0400 +++ b/lisp/lib/skel/core/obj.lisp Sun May 26 16:34:24 2024 -0400 @@ -327,6 +327,24 @@ (write-sxp-stream self out :fmt fmt)) (unless *keep-ast* (setf (ast self) nil)))) +(defmethod write-sxp-stream ((self sk-config) stream &key (pretty t) (case :downcase) (fmt :pretty)) + (case fmt + (:pretty + (if (listp (ast self)) + (with-open-stream (st stream) + (loop for (k v . rest) on (ast self) + by #'cddr + unless (or (null v) (null k)) + do + (write k :stream stream :pretty pretty :case case :readably t :array t :escape t) + (write-char #\space st) + (if (or (eq (type-of v) 'skel) (subtypep (type-of v) 'structure-object)) + (write-sxp-stream v stream :fmt fmt) + (write v :stream stream :pretty pretty :case case :readably t :array t :escape t)) + (write-char #\newline st))) + (error 'sxp-fmt-error))) + (t (write (ast self) :stream stream :pretty pretty :case case :readably t :array t :escape t)))) + (defclass sk-system-config (sk-config sk-meta) ()) (defun default-sk-system-config () diff -r 73c8c1297989 -r fe7f583d8b02 lisp/lib/skel/core/util.lisp --- a/lisp/lib/skel/core/util.lisp Sun May 26 16:02:37 2024 -0400 +++ b/lisp/lib/skel/core/util.lisp Sun May 26 16:34:24 2024 -0400 @@ -12,16 +12,16 @@ (defun init-user-skelrc (&optional (file *user-skelrc*)) "Initialize a skelrc configuration based on the currently active *SKEL-USER-CONFIG*. Defaults to ~/.skelrc." - (sk-write-file *skel-user-config* + (sk-write-file *skel-user-config* :path file - :fmt :pretty)) + :pretty t)) (defun init-system-skelrc (&optional (file *system-skelrc*)) "Initialize a system skelrc configuration based on the currently active *SKEL-SYSTEM-CONFIG*." (sk-write-file *skel-system-config* :path file - :fmt :pretty)) + :pretty t)) (defun load-user-skelrc (&optional (file *user-skelrc*)) "Load a user-skelrc configuration from FILE. Defaults to *USER-SKELRC*.