I am trying to write a function that prints the name of the current buffer to the file in the current buffer in its first line. For example, if the file is called "test.el", when invoking such function, the result should be:
test.el ; rest of file
However, I am stuck with the following non-working function:
(defun my-heading () "Write the name of the present file on the first line." (append-to-file (point-min) ; start: beginning of buffer 200 ; end: I don't know when to stop (buffer-name) ; filename ))
Moreover, in the manual page for the function
append-to-file, it is written:
Don’t use these functions [
write-region] to write to files that are being visited; that could cause confusion in the mechanisms for visiting.
So, how can I write a function that appends text to the beginning of my current file?