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.

  • is (append (read v) '((thing5 . thing6))) what you're looking for? – mutbuerger Dec 1 '15 at 20:18
  • 2
    What is f-read-text ? – phils Dec 1 '15 at 20:24
  • Probably from f.el – npostavs Dec 1 '15 at 20:29
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 ")"))
  • After your (setq v (read (f-read-text "s.el"))) a (push '(thing5 . thing6) v) does exactly what I wanted. Thanks. – 147pm Dec 2 '15 at 3:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.