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.
The emacs editing mode is entered when you enable either the emacs or gmacs option. The only difference between these two modes is the way each handles the Ctrl-T edit command. To edit, move the cursor to the point needing correction and insert or delete characters or words, as needed.
To enter Emacs, type emacs at the shell prompt. When you want to leave Emacs for a short time, type a C-z and Emacs will be suspended. To get back into Emacs, type %emacs at the shell prompt. To quit Emacs permanently, type C-x C-c.
Emacs helps you be productive by providing an integrated environment for many different kinds of tasks: All of the basic editing commands (and there are lots of them) are available no matter what you're trying to do: write code, read a manual, use a shell, or compose an email.
To execute Control commands, written as CTRL-letter , hold down the Control key while typing the letter indicated. To execute Escape commands, written as ESC letter , press the Escape key (once) and then type the letter indicated. and hit the Return key.
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
(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))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With