Elisp: Read File Content as String or Lines

By Xah Lee. Date: . Last updated: .

Read File Content into a String

(defun get-string-from-file (filePath)
  "Return file content as string."
    (insert-file-contents filePath)
;; 2010-09-02 thanks to Pascal J Bourguignon and TheFlyingDutchman [zzbba…@aol.com]

Read File Content as List of Lines

(defun read-lines (filePath)
  "Return a list of lines of a file at filePath."
    (insert-file-contents filePath)
    (split-string (buffer-string) "\n" t)))

Elisp, File, Buffer

Elisp, Process Lines