Skip to content

How to modify the content of a file in Emacs Lisp?

(let ((buff (find-file-noselect "./foo")))
  (with-current-buffer buff
    (goto-char (point-min))
    (insert "foo\n")
    (goto-char (point-max))
    (insert "bar\n")
    (save-buffer))
  (kill-buffer buff))