How do I read the first line of a textfile into a string without displaying the buffer

I can do

(load-buffer (string->url path))

and then

(go-start)
(tree->string (paragraph-tree))

to get the first line of the file with filepath path. Can I do this without having to switch the view to the file?

1 Like

Have a look if buffer-load followed by buffer-get-body does what you want.

I managed to solve the issue differently using

(string-load (string->url path))

this returns the contents of the file with path path as a string.

1 Like