diff options
Diffstat (limited to '.emacs.d/mysnippets/text-mode/emacs-lisp-mode/file.read-lines')
| -rw-r--r-- | .emacs.d/mysnippets/text-mode/emacs-lisp-mode/file.read-lines | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/.emacs.d/mysnippets/text-mode/emacs-lisp-mode/file.read-lines b/.emacs.d/mysnippets/text-mode/emacs-lisp-mode/file.read-lines new file mode 100644 index 0000000..b4a1942 --- /dev/null +++ b/.emacs.d/mysnippets/text-mode/emacs-lisp-mode/file.read-lines | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | #name : read lines of a file | ||
| 2 | #contributor : Xah Lee | ||
| 3 | # -- | ||
| 4 | (defun read-lines (filePath) | ||
| 5 | "Return a list of lines in FILEPATH." | ||
| 6 | (with-temp-buffer | ||
| 7 | (insert-file-contents filePath) | ||
| 8 | (split-string | ||
| 9 | (buffer-string) "\n" t)) ) | ||
| 10 | |||
| 11 | ;; process all lines | ||
| 12 | (mapc | ||
| 13 | (lambda (aLine) | ||
| 14 | (message aLine) ; do your stuff here | ||
| 15 | ) | ||
| 16 | (read-lines "inputFilePath") | ||
| 17 | ) \ No newline at end of file | ||
