You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This way, the user can override file contents while still having most of Nfiles benefits like file fetching, caching, smart parsing (in case they only provided raw contents). In particular, allowing to pass contents will simplify user scripts and blocker hostlists in Nyxt. Dramatically.
The text was updated successfully, but these errors were encountered:
A specialization of read-file seems to do what you want, no?
That's the problem: one has to define a method just to have custom contents for the file. This is especially problematic with user-facing configuration.
Here's how we currently handle blocker-mode hostlist in Nyxt. We define the class with a slot representing the contents of the file and poorly mimicking file management that Nfiles provides natively:
(define-class hostlist (files:data-file nyxt-remote-file)
((hosts
'()
:type (or (consstring*) null)
:documentation"List of hosts to ignore.This is useful to reference hosts manually instead of via `nfiles:url'.")
#| ... |#)
#| ... |#)
(defmethodhosts:around ((hostlist hostlist))
(or (call-next-method)
(let ((path (files:expand hostlist)))
(unless (uiop:file-exists-p path)
(echo "Updating hostlist ~s..." path))
(setf (slot-value hostlist 'hosts)
(files:content hostlist
:force-update (not (uiop:file-exists-p path)))))))
Then, when the user configures it, they have to provide hosts. And they have to provide it as this custom slot value.
It will simplify the design a lot if Nfiles allowed to provide contents at initialization. This way, one doesn't have to add proxy slots and has automatic (de)serialization, caching etc.
With such a change, hostlist initialization would look like:
This way, the user can override file contents while still having most of Nfiles benefits like file fetching, caching, smart parsing (in case they only provided raw contents). In particular, allowing to pass contents will simplify user scripts and blocker hostlists in Nyxt. Dramatically.
The text was updated successfully, but these errors were encountered: