2

When I do this (setq v (f-read-text "s.el")) where s.el is of this form

((thing1 . thing2) (thing3 . thing4))

I get v back as one long string. And (setq v (append (f-read-text "s.el"))) doesn't seem to change things to a list. I want to do a push or add-to-list an item, but I seem to be adding that item to a list containing a big string. I'd like to return the contents of s.el as a list and then do the push or add-to-list. Then I need to write it back out, again not as a string.

Drew
  • 75,699
  • 9
  • 109
  • 225
147pm
  • 2,907
  • 1
  • 18
  • 39

1 Answers1

3

If your file contains just one lisp form, all you need to do is

(setq v (read (f-read-text "s.el")))

(see Input Functions).

If there are several forms, like (a b) (c d), you will need to read in cycle using read-from-string or do

(read (concat "(" my-string ")"))
sds
  • 5,928
  • 20
  • 39
  • After your `(setq v (read (f-read-text "s.el")))` a `(push '(thing5 . thing6) v)` does exactly what I wanted. Thanks. – 147pm Dec 02 '15 at 03:19