changelog shortlog graph tags branches files raw help

Mercurial > core / changeset: write-sxp-stream for sk-config

changeset 372: fe7f583d8b02
parent 371: 73c8c1297989
child 373: 9eb2c112aa16
author: Richard Westhaver <ellis@rwest.io>
date: Sun, 26 May 2024 16:34:24 -0400
files: lisp/lib/skel/core/obj.lisp lisp/lib/skel/core/util.lisp
description: write-sxp-stream for sk-config
     1.1--- a/lisp/lib/skel/core/obj.lisp	Sun May 26 16:02:37 2024 -0400
     1.2+++ b/lisp/lib/skel/core/obj.lisp	Sun May 26 16:34:24 2024 -0400
     1.3@@ -327,6 +327,24 @@
     1.4         (write-sxp-stream self out :fmt fmt))
     1.5     (unless *keep-ast* (setf (ast self) nil))))
     1.6 
     1.7+(defmethod write-sxp-stream ((self sk-config) stream &key (pretty t) (case :downcase) (fmt :pretty))
     1.8+  (case fmt
     1.9+    (:pretty
    1.10+     (if (listp (ast self))
    1.11+         (with-open-stream (st stream)
    1.12+           (loop for (k v . rest) on (ast self)
    1.13+                 by #'cddr
    1.14+                 unless (or (null v) (null k))
    1.15+                 do 
    1.16+                    (write k :stream stream :pretty pretty :case case :readably t :array t :escape t)
    1.17+                    (write-char #\space st)
    1.18+                    (if (or (eq (type-of v) 'skel) (subtypep (type-of v) 'structure-object))
    1.19+                        (write-sxp-stream v stream :fmt fmt)
    1.20+                        (write v :stream stream :pretty pretty :case case :readably t :array t :escape t))
    1.21+                    (write-char #\newline st)))
    1.22+         (error 'sxp-fmt-error)))
    1.23+    (t (write (ast self) :stream stream :pretty pretty :case case :readably t :array t :escape t))))
    1.24+
    1.25 (defclass sk-system-config (sk-config sk-meta) ())
    1.26 
    1.27 (defun default-sk-system-config ()
     2.1--- a/lisp/lib/skel/core/util.lisp	Sun May 26 16:02:37 2024 -0400
     2.2+++ b/lisp/lib/skel/core/util.lisp	Sun May 26 16:34:24 2024 -0400
     2.3@@ -12,16 +12,16 @@
     2.4 (defun init-user-skelrc (&optional (file *user-skelrc*))
     2.5   "Initialize a skelrc configuration based on the currently active
     2.6 *SKEL-USER-CONFIG*. Defaults to ~/.skelrc."
     2.7-  (sk-write-file *skel-user-config* 
     2.8+  (sk-write-file *skel-user-config*
     2.9                  :path file
    2.10-                 :fmt :pretty))
    2.11+                 :pretty t))
    2.12 
    2.13 (defun init-system-skelrc (&optional (file *system-skelrc*))
    2.14   "Initialize a system skelrc configuration based on the currently active
    2.15 *SKEL-SYSTEM-CONFIG*."
    2.16   (sk-write-file *skel-system-config*
    2.17                  :path file
    2.18-                 :fmt :pretty))
    2.19+                 :pretty t))
    2.20 
    2.21 (defun load-user-skelrc (&optional (file *user-skelrc*))
    2.22   "Load a user-skelrc configuration from FILE. Defaults to *USER-SKELRC*.