Now that the T-deck has sd-card support I’ve been using save-image and edit to create new functionality that is persistent. Unfortunately when I update the firmware these functions are no longer loadable. So I started exporting using the pprintall function to save a text version of the functions that I had written to a separate file:
(load-image)
(with-sd-card (str "image.txt" 2)
(pprintall str))
When writing a function to load the stored functions from the text file, I realized that I was starting to write a package loader of sorts:
(defun load-package (filename)
(with-sd-card (str filename)
(loop
(let (ln (eval (read str)))
(unless ln (return nothing)))))))
Which lead me to wanting to write a function that given a package file name, and a list of symbols, would write these out to a file to be loaded later:
(defun save-package (filename lst)
(with-sd-card (str filename 2)
(dolist (f lst)
(pprint f str))))
(defun add-to-package (filename list)
(with-sd-card (str filename 1)
(dolist (f lst)
(pprint f str))))
Sadly pprint either prints only the name if they are quoted, or the lambda of the symbol if given a list of symbols
(save-package "packages.lsp" '(save-package add-to-package))
At which point I realized I would need to write out a describe
function that returns the whole definition of a function, and I might as well have it do all symbols, which lead me to coming here and seeing if anyone has put any thought into this. Could this be build into edit
. Do we need to include shadowing, gensym and other package management components, or should a package just load into the global space.
Thoughts?