Read from a file into a Emacs lisp list

Viewed 3673

I have the following file data.txt

A
B
C
D

I would like to read the contents of this file into a Lisp list, like

(defun read-list-from-file (fn)
  (interactive)
  (list "A" "B" "C" "D"))

(defun my-read ()
  (interactive)
  (let (( mylist (read-list-from-file "data.txt")))
    (print mylist t)))

How can I modify read-list-from-file such that it returns the same list, but instead reads from the file given as input argument fn.. Each line in the file should be a separate item in the list..

2 Answers
Related