Last active
August 6, 2017 09:19
-
-
Save phoe/b3c8424820317b9291036d3d2edf65e0 to your computer and use it in GitHub Desktop.
Pretty-printing function for config-like plists
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun pprint-plist (*standard-output* list) | |
"Pretty-prints a plist with newlines after each key-value pair. | |
This will break if not called at toplevel, but works well enough for my use case." | |
(pprint-logical-block (*standard-output* list :prefix "(" :suffix ")") | |
(loop for cell on list by #'cddr | |
do (write (first cell)) | |
(write-char #\Space) | |
(write (second cell)) | |
(when (cddr cell) | |
(terpri *standard-output*) | |
(write-char #\Space))) | |
(terpri *standard-output*))) | |
#| | |
Example of printed output: | |
(:DB-NAME "gateway" | |
:DB-USER "secret" | |
:DB-PASS "supersecret" | |
:DB-HOST "secret.ksi.ii.uj.edu.pl" | |
:DB-PORT 54321 | |
:DB-USE-SSL :NO | |
:TEST-DB-NAME "gateway-test" | |
:TEST-DB-USER "secret" | |
:TEST-DB-PASS "supersecret" | |
:TEST-DB-HOST "secret.ksi.ii.uj.edu.pl" | |
:TEST-DB-PORT 54321 | |
:TEST-DB-USE-SSL :NO | |
) | |
|# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment