Elisp: Read File
If you don't care about speed, use
to open a file into buffer. Then you can process it.
to save, like you would with using emacs.
If the file doesn't exit, it'll be created when you save it.
has lots side-effects. It will call all functions in
find-file-hook. Many packages and major modes add stuff to that hook.
It'll load a major mode (which does syntax coloring, usually very slow),
it'll record undo for any modification in the buffer.
[see Emacs Lisp Text Processing: find-file vs with-temp-buffer]
Open File for Reading in Batch Script
To process thousands of files, read only, use
(defun my-process-file (fPath) "Process the file at path FPATH …" (with-temp-buffer (insert-file-contents fPath) ;; process it … ))
(info "(elisp) Current Buffer")
Read File as String or List of Lines
Elisp: Read File Content as String or List of Lines