Elisp: Open File, Read, Possibly Write
Here's a idiom for efficiently opening a file, read content, and possibly write back to file.
(defun my-process-file (fPath) "Process the file at path FPATH" (let ((fileChanged-p nil)) (with-temp-buffer (insert-file-contents fPath) ;; process text ;; set fileChanged-p to t or nil (when fileChanged-p (write-region (point-min) (point-max) fPath)))))
Elisp, File, Buffer
- Elisp: Buffer Functions
- Elisp: Read File
- Elisp: Read File Content as String or Lines
- Elisp: Write File
- Elisp: Open File, Read, Possibly Write
- Elisp: File and Directory Functions
- Elisp: Get File Info
- Elisp: File Path Functions
- Elisp: Walk Directory, List Files
- Elisp: Walk Directory by Depth 🚀
- Elisp: Get Dired Marked Files