Home
Head's Up: I'm in the middle of upgrading my site. Most things are in place, but there are something missing and/or broken including image alt text. Please bear with me while I'm getting things fixed.

Read Files Contents Into A Temporary Emacs Buffer With Lisp

This started as an example way to read file contents. It's also the code that is setup to use [TODO: Code shorthand span ] in a file.

This reads a file into a temporary buffer, deletes everything up to the first occurance of the word ` brown ` , and then outputs what's left.

elisp
(with-temp-buffer
 (insert-file-contents "input.txt")
 (goto-char (point-max))
 (delete-region
  (point-min) 
  (search-forward "__END__" nil nil -1))
 (delete-region
  (point-min) 
  (search-forward "__END__\n" nil nil))
 (append-to-file nil nil "output.txt"))