Mac – How to get emacs to insert text into an arbitrary file


I'm trying to create a function that inserts text into an arbitrary file without switching to that file's buffer.

I know this could be done with echo, but is there a way to do it using only elisp?

Best Answer

Try this function:

(defun append-string-to-file (string filename)
  "Appends STRING to FILENAME."
  (append-to-file string nil filename))
Related Question