lem-core:config-plist errors out when ~/.lem/config.lisp is empty#902
Merged
cxxxr merged 1 commit intolem-project:mainfrom Aug 11, 2023
Merged
lem-core:config-plist errors out when ~/.lem/config.lisp is empty#902cxxxr merged 1 commit intolem-project:mainfrom
cxxxr merged 1 commit intolem-project:mainfrom
Conversation
Member
|
I think it very good PR. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If .lem/config.el is empty it gives the following error:
It looks like it is coming from src/config.lisp. This problem comes
about whether I use sdl2 or ncurses. I just happen to use sdl2.
A bunch of junk that no one cares about:
sdl2::sdl-main-thread calls sdl2::handle-message which calls
sdl2::create-display which calls lem-sdl2/font:make-font-config which
calls a constructor %make-font-config which constructs a struct. That
struct has multiple slots which call lem-core:config to get config
information.
The actual problem:
If $HOME/.lem/config.lisp is empty we get an error because
lem-core:config (from src/config.lisp) calls lem-core:config-plist
which uses uiop:read-file-form. But uiop:read-file-form uses
uiop:slurp-stream-form which reads a file using loop inside
uiop:slurp-stream-forms, the whole list gets returned to
slurp-stream-form where it then calls uiop:access-at to access
whatever you set the at arg to (which in this case wasnt set so at = 0
and it tries to access element 0, but since the file is empty there is
no first element in that list and it errors out saying
index-too-large-error.
Solution: Just use uiop:read-file-forms
It gets called anyways and you can just do a check in lem-core:config
to see if its nil or not.
Note 1
Im not sure exactly how the plist was supposed to work in the rest of
the code, but Im assuming that it is one big s-exp contains the plist,
so that config.lisp is something like this:
In which case I think I rewrote lem-core:config correctly, but if that
was not the case then it might be that the call to car on the plist
should be removed.
Note 2
It might make more sense to move the call to car into the let form: