I am attempting to write a function which, given a file path, will load the contents of that file and append it to a list. The end goal is to have one file for each org-capture template, and to load them from a list of files or an org-table.
My problem is that the load and load-file functions only return t if the load is successful.
What function can I use to return the contents of a file as an expression?
for example, given the file test.el:
'("foo" "bar" "baz" "fnord")
How can I achieve the following:
(mysterious-function "~/test.el")
=> '("foo" "bar" "baz" "fnord")
Thanks in advance
(defun mysterious-function (filename)
(setq filename (expand-file-name filename))
(with-temp-buffer
(insert-file-contents filename)
(read (current-buffer))))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With