Reputation: 1339
I want the emacs lisp code to append some data to a log file from emacs. The log file is large so I don't want to read it into memory.
I just need to open the log file, append some data to it, close it. I never need to see or manually edit the content.
Upvotes: 13
Views: 4267
Reputation: 1
(f-write (format "%s" \<your list or what you what> ) 'utf-8\<or other encoding> "\<absolute file path>")
then go to the end of this line on closing braket and press C-e , go to the terminal cat + file, enjoy
Upvotes: 0
Reputation: 41078
You can use the append-to-file
lisp function.
Append the contents of the region to the end of file filename. When called from a function, expects three arguments, start, end and filename. start and end are normally buffer positions specifying the part of the buffer to write.
If start is nil, that means to use the entire buffer contents.
If start is a string, then output that string to the file instead of any buffer contents; end is ignored.
More information is available here
Upvotes: 15
Reputation: 17422
(defun add-log-entry (log-message log-file)
"Add a given message string to the end of a file."
(append-to-file log-message nil log-file))
Upvotes: 8